21. What are the ways of preserving data on a Web Form in ASP.NET?
ASP.NET has introduced view state to preserve data between postback events. View state can't avail data to other web form in an application. To provide data to other forms, you need to save data in a state variable in the application or session objects.
22. 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 view state is not fully loaded during this event
23. How can we identify that the Page is Post Back?
Page object has an “IsPostBack” property, which can be checked to know that is the page posted
24. What is event bubbling?
Server controls like Datagrid, DataList, and 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
events to parent it is termed as event bubbling.
25. How do we assign page specific attributes?
Page attributes are specified using the @Page directive.
26. How do we ensure viewstate is not tampered?
Using the @Page directive and setting ‘EnableViewStateMac’ property to True.
27. What is AppSetting Section in “Web.Config” file?
Web.config file defines configuration for a web project. Using “AppSetting” section, we can
define user-defined values. Example below defined is “Connection String” section, which will be
used through out the project for database connection.
28. How can we create custom controls in ASP.NET?
User controls are created using .ASCX in ASP.NET.
After .ASCX file is created you need to two
things in order that the ASCX can be used in project:.
- Register the ASCX control in page using the
<%@ Register tag prefix="Accounting" Tag name="footer"
- Now to use the above accounting footer in page you can use the below directive.
29. How many types of validation controls are provided by ASP.NET?
There are six main types of validation controls:-
It checks whether the control have any value. It is used when you want the control should not be
It checks if the value in validated control is in that specific range. Example TxtCustomerCode
should not be more than eight lengths.
It checks that the value in controls should match some specific value. Example Textbox TxtPie
should be equal to 3.14.
When we want the control, value should match with a specific regular expression.
It is used to define User Defined validation.
It displays summary of all current validation errors on an ASP.NET page.
30. Explain “AutoPostBack”?
If we want the control to automatically post back in case of any event, we will need to check this
attribute as true. Example on a Combo Box change we need to send the event immediately to the
server side then set the “AutoPostBack” attribute to true.
31. How can you enable automatic paging in Data Grid?
Following are the points to be done in order to enable paging in Data grid:-
- Set the “Allow Paging” to true.
- In PageIndexChanged event set the current page index clicked.
32. What is the difference between “Web.config” and “Machine.Config”?
“Web.config” files apply settings to each web application, while “Machine.config” file apply
settings to all ASP.NET applications.
33. What is a SESSION and APPLICATION object?
Session object store information between HTTP requests for a particular user, while application
object are global across users.
34. What is the difference between ‘Server.Transfer’ and ‘response.Redirect’ ?
Following are the major differences between them:-
‘Response.Redirect’ sends message to the browser saying it to move to some different page,
while server. Transfer does not send any message to the browser but rather redirects the user
directly from the server itself. So in ‘server.transfer’ there is no round trip while
‘response.redirect’ has a round trip and hence puts a load on server.
Using ‘Server.Transfer’ you cannot redirect to a different from the server itself. Example if your
server is www.gmail.com you can not use server.Transfer to move to www.facebook.com but
yes, you can move to www.gmail.com/travels, i.e. with in websites. Cross server redirect is
possible only by using Response. Redirect.
With ‘server.transfer’ you can preserve your information. It has a parameter called as
“preserveForm”. Therefore, the existing query string etc. will be able in the calling page.
If you are navigating within the same website use “Server. Transfer” or else go for “response.
35. What is the difference between Authentication and authorization?
This can be a tricky question. These two concepts seem altogether similar but there is wide range
of difference. Authentication is verifying the identity of a user and authorization is process where
we check does this identity have access rights to the system.. Authorization is the process of
allowing an authenticated user access to resources. Authentications always proceed to
Authorization; even if your application lets anonymous users connect and use the application, it
still authenticates them as anonymous.
36. What is impersonation in ASP.NET?
By default, ASP.NET executes in the security context of a restricted user account on the local
machine. Sometimes you need to access network resources such as a file on a shared drive, which
requires additional permissions. One way to overcome this restriction is to use impersonation.
With impersonation, ASP.NET can execute the request using the identity of the client who is
making the request, or ASP.NET can impersonate a specific account you can specify the account
the client side?
validate the validation controls at the client side
38. If client side validation is enabled in your Web page, does that
mean server side code is not run.
However, note that does not mean that server side checks on custom validators do not execute. It
does this redundant check two times, as some of the validators do not support client side
39. What are Value types and Reference types?
Value types directly contain their data that are either allocated on the stack or allocated in-line in
a structure. So value types are actual data.
Reference types store a reference to the value's memory address, and are allocated on the heap.
Reference types can be self-describing types, pointer types, or interface types. You can view
reference type as pointers to actual data.
Variables that are value types each have their own copy of the data, and therefore operations on
one variable do not affect other variables. Variables that are reference types can refer to the same
object; therefore, operations on one variable can affect the same object referred to by another
variable. All types derive from the System. Object base type.
40. what is the difference between Cache object and application object?
The main difference between the Cache and Application objects is that the Cache object provides
cache-specific features, such as dependencies and expiration policies.