Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > custom control viewstate problem

Reply
Thread Tools

custom control viewstate problem

 
 
Lachlan James
Guest
Posts: n/a
 
      01-05-2005
Hello,

I have a custom control (extends WebControl and implements
INamingContainer) that is bound & added to the page
dynamically in the Page_Load method. The control is also
rebound again when I handle a click event for a button on
that same page.

This means that potentially the control is added & bound
inside the Page_Load, then again when the datasource
changes in the click event handler.

Not that I must re-add the controls each time in the
Page_Load otherwise they disappear because they are
dynamically added.

That seems straight forward, but for some reason the
ViewState for the control is lost when the control is re-
bound & re-added in the click event handler. The custom
control has a property which it stores in ViewState, but
this gets re-set when it is re-bound & re-added.

Correct me if I am wrong but I thought the purpose of
viewstate is to persist data across postbacks, why would
this property be reset when I re-bind and re-add it to the
page inside the click event handler?

Thanks, Lachlan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
custom control viewstate problem - please help so i can sleep Walter ASP .Net 0 10-11-2006 10:27 PM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Building Controls 2 05-22-2005 10:38 AM
Failed to load viewstate. The control tree into which viewstate... Josema ASP .Net Web Controls 0 05-09-2005 10:58 AM
ViewState of the Composite Control composed of custom control whoisnidhee ASP .Net Web Controls 2 07-16-2004 08:05 AM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments