Groups | Blog | Home
all groups > asp.net > december 2004 >

asp.net : How to ignore postback values?


Bob Owens
12/27/2004 11:35:12 PM
Hi all,

I have an html form (generated by asp.net of course) with several
DropDowns and text boxes on it. I'd like to handle things such that
every time the form is posted back this information is saved (to a
database in my case, but that's not important here) and the various asp
elements are reset to their "default" values. In other words I don't
want the controls to keep their postback values.

Instead, they're in "Night of the Living Dead" mode. They keep coming
back with these postback values no matter what.

How can I force my controls to forget their previous state? I've
disabled the enableviewstate property on some of them, only to learn
that the viewstate is _not_ responsible for these things retaining
their values on postback.
Eliyahu Goldin
12/28/2004 11:35:03 AM
Viewstate is not the only source of data for controls. Have a look at
http://blogs.aspadvice.com/joteke/archive/2004/03/15/767.aspx

Eliyahu

[quoted text, click to view]

Hans Kesting
12/28/2004 11:43:10 AM
[quoted text, click to view]

If you redirect (to this same page) after you have saved all values, you
solve several things:
1) you remove the "ispostback", so all fields are initialized fresh
2) if the user refreshes the page, you don't save a second copy of the previous data
and the user doesn't get that "POST" warning.

Hans Kesting

AddThis Social Bookmark Button