Solved

How does setting EnableViewstate to false really function ?

Posted on 2003-10-28
9
432 Views
Last Modified: 2012-08-13
I have created a simple web application using Visual Studio.NET as follows :

<%@ Page Language="VB" EnableViewstate="false" %>
<HTML>
   <BODY>
      <FORM Runat="server">
         Enter Your Name : <asp:textbox Id = "tbxMessage" Runat="server"/>
         <asp:button Id="btnSubmit" Text="Submit" Runat="server"/>      
      </FORM>
   </BODY>
</HTML>

I believe after submitting the page with some text in the text box the page should be re-displayed with the textbox being empty in the manner that a traditional asp page works, since I've set the EnableViewstate attribute to "false".

However, when I've found after submitting the page, that it re-displays the text that was input into the text box after it returns.
When I checked the source of the returned page, it did display a ViewState hidden element in it.

I was trying to understand how exactly "viewstate" works by creating a simple page. Is my understanding of the viewstate as mentioned in the para immediately above incorrect ? What am I missing. Kindly guide me.
0
Comment
Question by:x666xchange
9 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9635445
x666xchange,
It would erase you history. You may try this as well :
 <FORM Runat="server" autocomplete="off">
        Enter Your Name : <asp:textbox Id = "tbxMessage" Runat="server"/>
        <asp:button Id="btnSubmit" Text="Submit" Runat="server"/>      
     </FORM>

-set the property for autocomplete="false"
0
 
LVL 4

Expert Comment

by:kblack15217
ID: 9635456
Try using EnableViewState="false".  Caps sensative.  Your understading of viewstate is correct
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 9635487
In case this helps:

http://www.w3schools.com/aspnet/aspnet_viewstate.asp


Caching issue?

Fritz the Blank
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:x666xchange
ID: 9671675
I have tried setting autocomplete to "false" aswell as "off" for the form. Even tried setting the AUTOCOMPLETE feature directly in IE to unchecked.

None of the above worked. Any other suggestions please. Just can't figure out what's going wrong.
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 9676498
x666xchange,
It's  autocomplete ="off", if you set this property, your previous data wouldn't display again. However, if you prefer which control cant display the previous data, simply set this property inside the control.

<FORM Runat="server" autocomplete="off"> <---------All the control inside <Form> wouldn't display the history input

<Input Type="Text" id="txtInput" autoComplete="off"> <--reset history only for this control.

If autocomplete property not your main problems, let figure out the problems from EnableViewstate property.
For your info., EnableViewstate is set to True by default. To set it to false for all the page resist inside your project, just simply set in inside web.config. I think you have set it to true in someway, try to check again.

Regards
x_com
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 11632571
to x_com?

FtB
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
currencylayer API intergrate to ASP 25 65
Issue with Loop 4 50
show region if a selection is made on a drop down menu 3 56
Choose the older file FSO 6 42
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now