ASP.Net Interview Questions and Answers

    16 Votes

138) Why to set the property – EnableViewState to true?

Purpose of view state is to persist the state across postback. “EnableViewState” property is available at control and page level. Once we set it to TRUE, viewstate for a Control/Page will be enabled.

139) Why to use “runat=server” for HTML element?

HTML elements are treated as text by default. Once we add “runat=server” attribute to HTML element, it will be treated as a server control. If we add “runat=server” attribute we have to make sure this element is in <form> tag because it indicates that form is processed by server.

140) Can we store the dataset into viewstate? If yes, how?

Yes we can store the dataset into viewstate. We have to serialize the dataset and store it into viewstate.

141) How can we convert sql2000 numeric to integer in ASP.NET?

sqlParameter objTest=new sqlParameter();
objpara=objDataadapter.UpdataCommand.Parameter.Add("@Quantity",SqlDbType.Int);
objpara.SourceColumn="Quantity";
objTest.SourceVersion=DataRowVersion.Current; 

142) What you mean by DocType in ASP.NET?

XHTML Web pages should contain DOCTYPE, which identifies the page as XHTML. ASP.NET would not create DOCTYPE declaration when it’s rendered.

143) What is meant by runtime hosts?

Runhosts are special type where CLR is managed and executed.

144) What you mean by HTTPContext?

This is in System.Web namespace,this is the best way for reading server response at runtime.

Eg: HttpContext.Current.Items.Add("ERRORMESSAGE ", exception.Message);

145) Why to use Hidden Fields in ASP.NET?

Hidden fields are best way for exchanging the data between client (browser) and server. These controls are not visible in web page but can be accessed from javascript or Jquery.

146) What is the difference between Hidden Field and Textbox with Visible=false?

Hidden Field can be accessed from javascript or Jquery, whereas Textbox with Visible = false is not accessible from javascript or Jquery.

147) How do you decide on when to go for caching?

In case in our application, we need to store large amount of data and if it is the master data (which does not change most often) then we can use caching for storing this data.

148) What is the role of CSS in web pages in ASP.NET?

Cascading Style Sheet (CSS) is used to style the pages or controls which is visible to the user. CSS can be created in .css files and can be included this in our web pages.

149) What does mean Stateless?

Stateless mean, if the entity does not remember its previous state. HTTP is stateless protocol because it does not remember its old state (request) done. For this stateless feature ASP.NET provides state management options like Session, Cookies, Viewstate etc.

150) What does partial mean in ASP.NET?

We have the option of splitting the single class file into multiple parts. Using partial keyword, we can split the logic of single class into multiple class files with the same class name. Advantage of this would be – We will end up creating only one object for the class.

151) What could be best way to handle the data more than 10k in Datagrid?

Using dataset would be a feasible solution. Dataset will again have datatables in it. It’s easy to use LINQ to Dataset to filter the data from dataset and binding it to Datagrid.

152) Explain Page.IsValid?

This property will let you know whether all validation in a page succeeded or not.

153) Is it possible to use javascript from codebehind files in ASP.NET?

Yes we can register the javascripts from codebehind files like below –

Use method - Page.RegisterStartupScript() or use Page.RegisterClientScriptBlock().

154) How to use MessageBox without javascript in ASP.NET?

Add the reference of System.Windows.Forms library then use the method –

MessageBox(“Hi Testing”);

155) How can we change the timeout of session in ASP.NET?

Basically timeout of session is 20 minutes and if we want to change this timeout we can do in following way –

  • Change the Session time out in web.config. (In sessionstate tag change the timeout)
  • Change the Session time out in code using timeout property of session class.
Page 10 of 10

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

C# Interview Questions
.Net Framework Interview Questions and Answers
ADO.Net Interview Questions and Answers for Freshers, Experienced
ASP.Net MVC Interview questions and Answers
WCF Interview Questions and Answers
ASP.Net Web API Interview Questions
Top 50 Entity framework interview questions & answers