Why textbox is persisted when viewstate is off?

J

John Dalberg

I have a page with a few textboxes. When the page is posted, the textfields
retain their values even though I have viewstate turned off. It's turned
off in 2 different places.
- The control itself.
- Page.EnableViewState = false; in page_load.

How do I get the textboxes cleared after a postback without clearning them
programmatically?

J.
 
C

Craig Deelsnyder

I have a page with a few textboxes. When the page is posted, the
textfields
retain their values even though I have viewstate turned off. It's turned
off in 2 different places.
- The control itself.
- Page.EnableViewState = false; in page_load.

How do I get the textboxes cleared after a postback without clearning
them
programmatically?

J.

They get automatically populated with the forms' POST values. ViewState
only stores what .NET can't get from the POST data.

Don't know how to do this w/out programmatically clearing them, outside of
using some JS on the client side. Perhaps someone else knows of a
workaround...
 
S

Steve C. Orr [MVP, MCSD]

Textboxes don't use viewstate to retain their value property.
Standard HTML provides a value property for textboxes so this is what
ASP.NET uses in this case.
Assuming your textboxes start out blank initially, you could try code like
this to get the page to forget its values:

Response.Redirect(".")

The idea is that you are not posting back to your page, you are requesting a
fresh copy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top