Prizes & Awards
My Profile
Active Members
TodayLast 7 Days
more...
|
New Feature: Community Sites:
Create your own .NET community website and start earning from Google AdSense !
It's Free !
|
ASP.NET Viewstate
|
================================================================= Viewstate ================================================================= What is Viewstate? It holds a value when a form is posted. Advantages:
i) No server resources. ii) Security. iii) Simplicity. iv) Flexibility.
Disadvantages:
i) It can have a negative impact on page loading performance, if large amounts of data stored in viewstate. ii) Does not track across pages. Viewstate information does not automatically transfer from page to page. With the session approach, values can be stored in the session and accessed from other pages. This is not possible with viewstate, so storing data into the session must be done explicitly. ================================================================= Example for store the value in Viewstate:
Viewstate (“MyName”) = “Saravanan” Viewstate.Add (“MyName”,”Saravanan”) Response.Write (Viewstate (“MyName”)) ================================================================= FAQ ================================================================= Which property of a web page automatically saves the values of the page and of each control before the page is rendered? Viewstate ================================================================= What does the ‘EnableViewState’ Property do? Why would I want it on or off? True, if the control maintains its viewstate; otherwise false. ================================================================= Where is viewstate information stored? In HTML Hidden fields ================================================================= I have a class and I am creating an instance to store that instance in viewstate. How to define this class? < Serializable()>_ Public Class MyTest ================================================================= Can we disable the viewstate? ViewState can be disabled for a single control, for an entire page or for an entire web application. The syntax is: Disable viewstate for control (Datagrid in this example) < asp: datagrid EnableViewState="false" ... / > Disable viewstate for a page, using page directive < %@ Page EnableViewState="False" ... % > Disable viewstate for application through entry in web.config < Pages EnableViewState="false" ... / > ================================================================= Is it possible to encrypt viewstate when it’s passed over an unencrypted channel? Yes, Set the EnableViewStateMac to True and either modify the element in Machine.config to look like this: < machineKey validation=”3DES” …./> Or Add the following statement to Web.config: < machineKey validation=”3DES” /> ================================================================= Is it possible to protect viewstate from tampering when it’s passed over an unencrypted channel? Yes, Simply include an @ Page directive with an EnableViewStateMac=”true” attribute in each ASPX file you wish to protect, or include the following statement in Web.config: < pages EnableViewStateMac=”true” /> Mac means Message Authentication Code ================================================================= How to control viewstate on individual controls? You can set the EnableViewState property of the control. You should disable viewstate for any control that doesn't use it to guarantee optimum performance. ================================================================= Does the “EnableViewState” allows the page to save the users input on a form i) Yes ii) No ================================================================= What is ViewState used for? i) ViewState is a property that refers to the next event to be processed. ii) Any items that you add to ViewState are available within any page and by any user within an application. iii) ViewState enables you to preserve the values of variables across page requests for a particular user. iv) ViewState is a control that may be added to the page to store state in. v) ViewState enables you to preserve the state of a page when posting the page back to itself. ================================================================= Which one of the following do you use to disable ViewState? i) < %@ Page ViewStateDisable="true" %> ii) < %@ Page ViewStateEnable="false" %> iii) < %@ Page DisableViewState="true" %> iv) < %@ Page ViewState="false" %> v) < %@ Page EnableViewState="false" %> (Ans) ================================================================= How to define a class, which can be stored in viewstate? I have a class and I am creating an instance to store that instance in viewstate. How to define this class? i) Public Class MyTest Inherits Control ii)
|
Responses
|
No responses found. Be the first to respond and make money from revenue sharing program.
|
|