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

What is the easiest way to bring down any website in ASP.NET?

There is a simple way to bring down your ASP.NET 2.0 application. The only thing you have to do is to create simple html file called App_offline.htm and deploy it to your ASP.NET 2.0 web application root directory. The rest is handled by ASP.NET runtime internal routines.

The way app_offline.htm works is that you put the file in the root directory of the application. When ASP.NET sees it, it will shut-down the app-domain for the application (and not restart it for requests) and instead send back the contents of the App_offline.htm file in response to all new dynamic requests for the application. When you are done updating the site, just delete the file and it will come back online.
Default ContentType of Response.ContentType is…

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between the Theme and StylesheetTheme?

The StylesheetTheme attribute works same as the Theme attribute.The difference is that the when attributes are set locally on the page within a particular control, the attributes are overridden by the theme if you use the Theme attribute. They are kept in place, if you apply the page’s theme using the StylesheetTheme attribute. Suppose you have a text box control like the following:

<asp:Textbox ID=”TextBox1” Runat=”server”

ForeColor=”#ffffff” />


In this example, the ForeColor settings is overridden by the theme if you have
applied it using the Theme attribute in the Page directive. If, instead, you applied the theme using the StylesheetTheme attribute in the Page directive, the ForeColor settings remain in place, even if they are explicitly defined in the theme.
In your asp page, HTML tag and CacheControl will be specified…

NOTE: This is objective type question, Please click question title for correct answer.
What is the fastest way to concat strings in ASP.NET ? What should you do?

NOTE: This is objective type question, Please click question title for correct answer.
You want to only get changed data in a dataset which of the below is the best way ?

NOTE: This is objective type question, Please click question title for correct answer.
Which of the following does the actual .NET code execute ?

NOTE: This is objective type question, Please click question title for correct answer.
Garbage collector runs ?

NOTE: This is objective type question, Please click question title for correct answer.
How you can determine whether client is connected to server or not?

With some of the scenarions, you need to determine whether client has reset the connection or not. With
Response.IsClientConnected
, we can know whether client is connected to the server or not.
How to assign class to htmltablerow runtime?

With htmltablerow, you cant find property like class/cssclass.
With such situation, you need to add attribute of “Class” to the desired htmltablerow.
With below code, I am adding class “NavyYellow” to found tablerow “trMain”
Dim trMain As HtmlTableRow

trMain = CType(e.Item.FindControl("trMain"), HtmlTableRow)
trMain.Attributes.Add("class", "NavyYellow")

how to handle EmptyDataTemplate with repeater ?

Unlike gridview, you can’t find <EmptyDataTemplate> with repeater. You need to handle such situation some different way. One of the way to handle this is, to keep label(initially hidden) in the footer template of repeater. With ItemDataBound event, you can get item count of the repeater and from that count you can decide visibility of the label in footer.
How many ViewState objects can be created on an aspx page ?

NOTE: This is objective type question, Please click question title for correct answer.
What is Captacha Image and why it is used?

CAPTCHA =”Completely Automated Public Turing test to tell Computers and Humans Apart."

It means that it’s kind of test which a human can pass but a computer program cannot pass it. It is used almost in every site when you make a sign up. Captcha is an image with some distorted text. It can have only alphabets, numbers or both depend on the programmer.

It is used to stop spamming as using web bots the process of sign up or submitting feedback can be made automatic. But having Captcha as additional level input stops web bots from doing successful spamming as web bots cannot read Captcha image content.
What is smart navigation in .NET?

SmartNavigation is the property used in <%@ Page %> tag.
It works with 1.1 & versions before it.
For Version 2.0 and next instead of it we can use "SetFocus" and "MaintainScrollPositionOnPostBack".

Smart Navigation basically enhances a web pages in the following way:

1. The scroll position of a Web page is maintained after postback.
2. The element focus on a Web page is maintained during navigation.
3. Only the most recent Web page state is retained in the Web browser history folder.
4. The flicker effect that may occur on a Web page during navigation is minimized.
Does isMaxLengh work with multiline textbox ? How can you handle such situation?

No, isMaxLength doesn’t work with multiline textbox.
You need to handle such situation some other way. Javascript can be an option to deal with this situation.
You can use, following function to achieve the said functionality…
function isMaxLength(txtBox, length)

{
if(txtBox)
return (txtBox.value.length <= length-1);
}


Which can be used with multiline textbox as below…

<asp:TextBox ID="txtNotes" Width="92%" TextMode="MultiLine" Rows="6" runat="server" onkeypress='javascript:return isMaxLength(this,16);'                                   ></asp:TextBox>

You need to prefix something with the retrieved amount (Positive, negative, zeros). How will you handle this?

In such case you can use, custom numeric format string.
Example given below can make it clearer.

Dim num As Double

num = 100
Dim MyString As String = num.ToString("Test positive : #,##0.00;")
num = -100
MyString = num.ToString(";Test negative : [ $#,##0.00 ]")
num = 0
MyString = num.ToString(";;It's zero. :( :( ")

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