Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Viewstate access

Reply
Thread Tools

Viewstate access

 
 
Amr Al Jarhi
Guest
Posts: n/a
 
      11-25-2004
I have a webform, with a statically declared usercontrol in it...
the usercontrol is actually a webcontrol ( inherits from class
WebControl)
this control has some child controls created dynamically at the event:
CreateChildControls
obviously this event is fired before the viewstate is loaded, so i
cannot save or load anything from the viewstate.
the question is: how can i use the viewstate from inside the
usercontrol? Or if i cannot, what is the best practice to save and
load volatile data
between postbacks from within the usercontrol?
 
Reply With Quote
 
 
 
 
Ashish Kaila
Guest
Posts: n/a
 
      11-30-2004
Implement INamingContainer interface in your webcontrol and override
LoadViewState and SaveViewState to save the state of your control.
HTH
Ashish

"Amr Al Jarhi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have a webform, with a statically declared usercontrol in it...
> the usercontrol is actually a webcontrol ( inherits from class
> WebControl)
> this control has some child controls created dynamically at the event:
> CreateChildControls
> obviously this event is fired before the viewstate is loaded, so i
> cannot save or load anything from the viewstate.
> the question is: how can i use the viewstate from inside the
> usercontrol? Or if i cannot, what is the best practice to save and
> load volatile data
> between postbacks from within the usercontrol?



 
Reply With Quote
 
 
 
 
amr.aljarhi@gmail.com
Guest
Posts: n/a
 
      12-06-2004
Thank you Ashish for your reply. This approach was suggested to me, but
to my specific purpose I have found that it is a little complicated. I
thought that inheriting from webcontrol would be very similar to
inheriting from usercontrol. My problem was solved by inheriting from
usercontrol instead. I guess inheriting from the webcontrol class is
not very usefull, unless I want to inherit from a specific webcontrol,
like textbox, and utilize the base functionality. But obviuosly
inheriting from the general webcontrol class does not give any
particular advantage that I am aware of over inheriting from user
control.

 
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
Problems with ViewState: "function 'ViewState.get_Item' evaluated and returned null" Steph ASP .Net 2 05-11-2011 02:35 PM
Errors: Failed to load viewstate. & Validation of viewstate MAC failed. sck10 ASP .Net 6 09-01-2006 05:59 PM
Loading usercontrols, viewstate problem, slighly different from all others "viewstate uc problems" please help... ujjc001 ASP .Net 0 07-27-2005 01:52 PM
Viewstate errors... how do I get viewstate working? mark ASP .Net Building Controls 0 02-20-2004 02:17 PM
Corrupted ViewState (Yes, another issue concerning viewstate) Ben Rush ASP .Net 2 12-05-2003 04:17 PM



Advertisments