ASP.NET Interview Questions and Answers (1544) - Page 18

At which event Master Page and Content Page's contents are merged to build a single page?

NOTE: This is objective type question, Please click question title for correct answer.
Is it possible to assign Master Page Dynamically?

Yes. It's possible. You can assign master page in Pre_Init method of content page.
Can you access controls placed in master page in content page?

Yes. We can access it. Using FindControl method of Master Page class.

Master.FindControl("Header")

Can you access the master page control in content page without FindControl method of master page?

Yes. There is another way of accessing the master page control other than findcontrol() method. See below code:

MyMasterPage objMasterPage = this.Master;

objMasterPage.MasterPageTextBox1.Text = "Text set from Content Page.";

Is it possible to place a try block without a catch or a finally block?

No.

We cannot place try block without catch or finally block. A try block can only exists if there is a catch block or finally block.
See below given code. Will it run? try { Response.Write("In Try block"); } finally { Response.Write("In Finally block."); }

Yes, it will run.

A try block can exists without a catch block if there is finally block. Try block is only valid when there is either a catch block or finally block.
Select name of the file to which trace log is written?

NOTE: This is objective type question, Please click question title for correct answer.
What is CausesValidation Property in ASP.NET?

CausesValidation property determines whether validation must be performed on button click or not, if asp.net validation control are used. It can be either true or false. By default it is true.

It is mostly used for Cancel/Reset button, where we don't want to perform any kind of validations.

<asp:Button ID="btnCancel" runat="server" Text="Cancel"

Visible="false" CausesValidation="false" />

Suppose you have CausesValidation Property to False for a button and you are calling a javascript function onClientClick event of the button. Will your javascript function will be called?

Yes. It will be called. As CausesValidation property, if set to false then it will not perform any validations related to asp.net Validation controls.

Thanks,
Virendra Dugar
You need to combine two database fields: Employee id and Name (EmpID : Name) and display in a single column of DataGrid. How can you do it?

This can be achieved any of the two ways.
You can combine these two database fields in the template column of the gridview as shown below:
<asp:GridView ID="GridView1" runat="server">

<Columns>
<asp:TemplateColumn HeaderText="Name">
<itemtemplate>
<%# Container.DataItem("EmpID") %>, <%# Container.DataItem("Name") %>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:GridView>

Other way of doing the same is to perform operation at database side. Retrieve the combined value as some column and bind the same with the databound column of the gridview.
Database side(SQL):
Select empid + ‘ : ‘ + name as name from emps;
 <asp:GridView ID="GridView1" runat="server">

<Columns>
<asp:BoundField DataField="Name">
</Columns>
</asp:GridView>

More preferable way is the second one as it will be less combursome.
Can you diplay image with hyperlink field of gridview?

Yes, you can.
You just need to set its text property to the desired image.
Code below can make it clear:
<asp:GridView ID="GridView1" runat="server">

<Columns>
<asp:HyperLinkField Text="<img src='1.gif'/>" />
</Columns>
</asp:GridView>

Can you have multiple form tags in a page?

YES.
Page can have multiple form tags but only one of them can contain runat=”server” atrribute at a time.
Can you hash state information of URL ?

NOTE: This is objective type question, Please click question title for correct answer.
Your site is deployed on testing server and you make some change in web.config file stored on the server. What will happen to the user's who are accessing site at that time?

When you make any change in web.config file then IIS restarts automatically so all the session and application variables get reset. This can affect user drastically as their session is lost.
MaintainScrollPositionOnPostback will work in Ajax Postback.

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories