How to ignore viewstate of a previous request for particular control?

Posted by AaronLS on Stack Overflow See other posts from Stack Overflow or by AaronLS
Published on 2010-06-17T17:18:51Z Indexed on 2010/06/17 17:23 UTC
Read the original article Hit count: 170

Filed under:
|
|

I am dynamically generating controls, and sometimes I want to create a control and have it ignore the viewstate. For example, sometimes the user has clicked a button indicating they want a different form loaded, so the control tree I generate on postback is different from the original control tree. This is fine, except when I call Controls.Add then it tries to load the viewstate form the old controls into the new controls if the control tree structure is similar, and I want them to instead ignore that viewstate(and also ignore the postback values for input controls as well).

Can I do something like set the IDs of the controls or something that would allow me to conditionally prevent them from getting the viewstate/postback data of the previous request?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET