Asp.net Q/A Part 1

on 10:26 AM

Asp.net Q/A Part 1

What’ is the sequence in which ASP.NET events are processed ?
Following is the sequence in which the events occur :-
√ Page_Init.
√ Page_Load.
√ Control events
√ Page_Unload event.
Page_init event only occurs when first time the page is started, but Page_Load occurs in subsequent request of the page.

In which event are the controls fully loaded ?
Page_load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that viewstate is not fully loaded during this event.

How can we identify that the Page is PostBack ?

Page object has a “IsPostBack” property which can be checked to know that is the page posted back.

What is event bubbling ?

Server controls like Datagrid, DataList, Repeater can have other child controls inside them. Example DataGrid can have combo box inside datagrid. These child control do not raise there events by themselves, rather they pass the event to the container parent (which can be a datagrid, datalist, repeater), which passed to the page as “ItemCommand” event.As the child control send there events to parent this is termed as event bubbling.

How do we assign page specific attributes ?
Page attributes are specified using the @Page directive.

If we want to make sure that no one has tampered with
ViewState, how do we ensure it?
Using the @Page directive EnableViewStateMac to True.

What is the use of @ Register directives ?

@Register directive informs the compiler of any custom server control added to the page.

What’s the use of SmartNavigation property ?

It’s a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.
Note:- This is only supported for IE browser. Project’s who have browser compatibility as requirements have to think some other ways of avoiding flickering.

What is AppSetting Section in “Web.Config” file ?
Web.config file defines configuration for a webproject. Using “AppSetting” section we can define user defined values. Example below defined is “ConnectionString” section which will be used through out the project for database connection.

Where is ViewState information stored ?

In HTML Hidden Fields.

How many types of validation controls are provided by ASP.NET ?
There are six main types of validation controls :-
RequiredFieldValidator
It checks whether the control have any value. It's used when you want the control should not be empty.
RangeValidator
It checks if the value in validated control is in that specific range. Example TxtCustomerCode should not be more than eight length.
CompareValidator
It checks that the value in controls should match some specific value. Example Textbox
TxtPie should be equal to 3.14.
RegularExpressionValidator
When we want the control value should match with a specific regular expression.
CustomValidator
It is used to define UserDefined validation.
ValidationSummary
It displays summary of all current validation errors.
Note:- It's rare that some one will ask step by step all the validation controls. Rather they will ask for what type of validation which validator will be used. Example in one of the interviews i was asked how you display summary of all errors in the validation control...just uttered one word Validation summary.

Can you explain what is “AutoPostBack” feature in ASP.NET ?

If we want the control to automatically postback in case of any event, we will need to check this attribute as true. Example on a ComboBox change we need to send the event immediately to the server side then set the “AutoPostBack” attribute to true.

How can you enable automatic paging in DataGrid ?
Following are the points to be done in order to enable paging in Datagrid :-
√ Set the “AllowPaging” to true.
√ In PageIndexChanged event set the current pageindex clicked.
Note:- The answers are very short, if you have implemented practically its just a revision.If you are fresher just make sample code using Datagrid and try to implement this functionality.

What’s the use of “GLOBAL.ASAX” file ?
It allows to executing ASP.NET application level events and setting application-level variables.