Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dynamic controls and viewstate?

Reply
Thread Tools

dynamic controls and viewstate?

 
 
Abel
Guest
Posts: n/a
 
      06-30-2003
Hello -

How can I utilize ViewState when my webform has dynamically generated
controls?

Is there a way to add/retrieve values to/from viewstate so that I can use
ViewState? I'd rather not have to manually "manage state" in my webforms
for persistant control values if there is a way to use ViewState for this.

Any suggestions/how-to's/advice?

Much appreciated - thanks in advance.

Cheers!



 
Reply With Quote
 
 
 
 
Axel Dahmen
Guest
Posts: n/a
 
      06-30-2003
The way ASP.NET handles dynamically created controls is kind of a "hit & run". You *always* have to add your controls to the page in the Page_Load() event - even on postback. As soon as you did, you can retrieve their ViewState by iterating through the Controls[] tree.

HTH,
Axel Dahmen

----------------------------------
"Abel" <(E-Mail Removed)> schrieb im Newsbeitrag news:uUV#(E-Mail Removed)...
> Hello -
>
> How can I utilize ViewState when my webform has dynamically generated
> controls?
>
> Is there a way to add/retrieve values to/from viewstate so that I can use
> ViewState? I'd rather not have to manually "manage state" in my webforms
> for persistant control values if there is a way to use ViewState for this.
>
> Any suggestions/how-to's/advice?
>
> Much appreciated - thanks in advance.
>
> Cheers!
>
>
>


 
Reply With Quote
 
 
 
 
Axel Dahmen
Guest
Posts: n/a
 
      07-01-2003
The way you described it is exactly the way it works:

foreach (object oStr in Controls)
{
litPageParams.Text += oStr.Text + " | ";
}

Could you explain why this doesn't work for you?

Axel

----------------------------
"Abel" <(E-Mail Removed)> schrieb im Newsbeitrag news:(E-Mail Removed)...
> Sorry if I sent this to you...I CTRL+R'd from OutlookExpress...
>
> Have an example? How do I specify which control's viewstate to get?
> Is there something like: Page.Control.GetViewState(ctlName)?
>
> Something like this isn't working for me:
> foreach (object oStr in Controls)
> {
>
> litPageParams.Text += oStr.ToString() + " | ";
>
> }
>
> "Axel Dahmen" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> The way ASP.NET handles dynamically created controls is kind of a "hit &
> run". You *always* have to add your controls to the page in the Page_Load()
> event - even on postback. As soon as you did, you can retrieve their
> ViewState by iterating through the Controls[] tree.
>
> HTH,
> Axel Dahmen
>
> ----------------------------------
> "Abel" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:uUV#(E-Mail Removed)...
> > Hello -
> >
> > How can I utilize ViewState when my webform has dynamically generated
> > controls?
> >
> > Is there a way to add/retrieve values to/from viewstate so that I can use
> > ViewState? I'd rather not have to manually "manage state" in my webforms
> > for persistant control values if there is a way to use ViewState for this.
> >
> > Any suggestions/how-to's/advice?
> >
> > Much appreciated - thanks in advance.
> >
> > Cheers!
> >
> >
> >

>
>


 
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
Dynamic table with dynamic controls and mySql ... opius ASP .Net 0 06-17-2011 08:55 AM
Controls.Count, Controls.IsSynchronized, and Controls.SyncRoot Nathan Sokalski ASP .Net 4 09-05-2007 03:27 AM
Dynamic Controls created by Dynamic Controls Ronald ASP .Net 2 01-17-2006 12:44 AM
Dynamic Variables? OR Dynamic Controls =?Utf-8?B?VGVyb3M=?= ASP .Net 1 08-10-2004 01:13 PM
Dynamic Controls, Placeholder, Retrieve Information from Dynamic Controls Denny Smolinski via .NET 247 ASP .Net Web Controls 1 05-04-2004 09:15 PM



Advertisments