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.
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.
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();
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?
146) What is the difference between Hidden Field and Textbox with Visible=false?
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.
Use method - Page.RegisterStartupScript() or use Page.RegisterClientScriptBlock().
Add the reference of System.Windows.Forms library then use the method –
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.