ViewstateEnabled=False
-
Hi, There are two textboxes and one button control in a Web page. We change the setting as ViewstateEnabled=False to both the textboxes. In button click event we have written the code to display TextBox1 value in TextBox2. The value is displaying in TextBox2 as well as it didn't remove from TextBox1 also even if both the textboxes ViewstateEnabled=False. What is the reason? Please answer. Thanks in advance
-
Hi, There are two textboxes and one button control in a Web page. We change the setting as ViewstateEnabled=False to both the textboxes. In button click event we have written the code to display TextBox1 value in TextBox2. The value is displaying in TextBox2 as well as it didn't remove from TextBox1 also even if both the textboxes ViewstateEnabled=False. What is the reason? Please answer. Thanks in advance
-
Hi, There are two textboxes and one button control in a Web page. We change the setting as ViewstateEnabled=False to both the textboxes. In button click event we have written the code to display TextBox1 value in TextBox2. The value is displaying in TextBox2 as well as it didn't remove from TextBox1 also even if both the textboxes ViewstateEnabled=False. What is the reason? Please answer. Thanks in advance
Elena2006 wrote:
The value is displaying in TextBox2 as well as it didn't remove from TextBox1 also even if both the textboxes ViewstateEnabled=False. What is the reason?
Well, the value you are seeing in text box are not loaded from
viewstate
. It will be loaded from the post back data. When you press the button, all the control values in the form will be send to server. When page renders, ASP.NET is capable to assign the values back to each controls correctly. To see viewstate in action here, consider changing some properties of text box inpage_load
event. Whenviewstate
is disabled for text box, you can see the changed property details are not persisting across post backs. :)Navaneeth How to use google | Ask smart questions
-
Hi, There are two textboxes and one button control in a Web page. We change the setting as ViewstateEnabled=False to both the textboxes. In button click event we have written the code to display TextBox1 value in TextBox2. The value is displaying in TextBox2 as well as it didn't remove from TextBox1 also even if both the textboxes ViewstateEnabled=False. What is the reason? Please answer. Thanks in advance
For the answer, first of all you need to know what actually happened during ASP.NET Page life cycle and ViewState. In the ASP.Net page life cycle, two events related with View State.
1. Load View State :
Where view state data is loading for the control and which happened beforePage_Load.
2. Save View State :
Where control data store in a hidden field before thePage_Render
. Now, If you disable theViewState
for the control it should store the view state data but, you are saying in Textbox, after you disabled the view state , control holds the data after postback, Here is the Trick, There is another event fired during Page Life Cycle, which is, LoadPostBack Data
:) ASP.NET controls which implementIPostBackEventHandler
will load its value from the appropriate postback data. This value is not read from view state but fromPostback
From and this is true for those control which implements theIPostBackEventHandler
andTextBox
is one such control Wink Hope this clears your doubts and This will helps you.cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net When you ask a question, remember to click "Good Answer", If the Answer is helps you.