niceguy971
asked on
C# -state
I found some good info about ViewState at http://www.extremeexperts.com/Net/Articles/ViewState.aspx. Below is an example (from above site) showing scenario where ViewState should be disabled for the textBox on the webform.
Can you please provide two or three other exampes showing that ViewState can be disabled for specific control on webform..and why it needs to be disabled ???
-------------
After loading the view state, the page reads client-side information through the Request object and uses those values to override most of the settings for the server controls. In general, the two operations are neatly separated and take place independently. In particular, though, the second operation—reading from Request.Form—in many situations ends up just overriding the settings read out of the view state. In this particular case the view state is only an extra overhead. For example consider the following case, we have one textbox in the page and a link button. If you are typing the some values in to the textbox and the posting the page using linkbutton. After postback, value in the textbox is retained though you enable or disable the viewstate. In this case you shouldnt enable viewstate for this textbox. Viewstate value is overridden by request.form values, since loadpostdata fires after loadviewstate view event in the Page lifecycle.
------------------
Thanks
Can you please provide two or three other exampes showing that ViewState can be disabled for specific control on webform..and why it needs to be disabled ???
-------------
After loading the view state, the page reads client-side information through the Request object and uses those values to override most of the settings for the server controls. In general, the two operations are neatly separated and take place independently. In particular, though, the second operation—reading from Request.Form—in many situations ends up just overriding the settings read out of the view state. In this particular case the view state is only an extra overhead. For example consider the following case, we have one textbox in the page and a link button. If you are typing the some values in to the textbox and the posting the page using linkbutton. After postback, value in the textbox is retained though you enable or disable the viewstate. In this case you shouldnt enable viewstate for this textbox. Viewstate value is overridden by request.form values, since loadpostdata fires after loadviewstate view event in the Page lifecycle.
------------------
Thanks
ASKER
So
1) For the Button control (when we do not change Text property ) it ALWAYS makes sense to Disable ViewState correct???
<asp:Button ID="Button1" runat="server" Text="Continue" EnableViewState="false" />
2) For the Label Control (which we use to Display the same text ) it ALWAYS makes sense to Disable ViewState correct???
<asp:Label ID="Label1" runat="server" Text="Please enter your Name" EnableViewState="false"></ asp:Label>
Thanks
1) For the Button control (when we do not change Text property ) it ALWAYS makes sense to Disable ViewState correct???
<asp:Button ID="Button1" runat="server" Text="Continue" EnableViewState="false" />
2) For the Label Control (which we use to Display the same text ) it ALWAYS makes sense to Disable ViewState correct???
<asp:Label ID="Label1" runat="server" Text="Please enter your Name" EnableViewState="false"></
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Open in new window
Read "The Role of ViewState" in this link: http://msdn.microsoft.com/en-us/library/ms972976.aspx#viewstate_topic9