Solved

How does setting EnableViewstate to false really function ?

Posted on 2003-10-28
9
435 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Time Conversions...both ways 2 24
Diminish Pop-up  in 3 seconds 7 70
Html fieldset fix its height and width 4 44
Replace value 2 34
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…

733 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