Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Viewstate for dynamic controls within dynamically loaded usercontr

Reply
Thread Tools

Viewstate for dynamic controls within dynamically loaded usercontr

 
 
steven scaife
Guest
Posts: n/a
 
      10-02-2008
Hi

I have been banging my head for a few days now with this issue.

I have a page that has several update panels everything is working fine
except for 1 thing.

I am creating a sort of wizard that will build a form that I plan to save to
a database
On stage 2 I load a usercontrol an unspecified number of times depending on
how many fields there will be and add it to an accordian pane.

So if I have two fields there will be two accordian panes this all works fine

Inside of the usercontrol there is a drop down list that adds textboxes
and/or dropdown lists to a placeholder.

When I postback the fields in the usercontrol maintain postback and the
dropdown list has the value selected however the dynamically created controls
appear but don't have any values that have been selected or entered into them.

All the controls have the same ids so thats not the problem.

The page on the load loops through and calls loadcontrol sets the id and
adds the control to the accordianpane which is added to the accoridan.

If i have my code in the init event the dropdown value is not preserved

TIA
 
Reply With Quote
 
 
 
 
steven scaife
Guest
Posts: n/a
 
      10-03-2008
Don't worry about this I sorted it.

for anyone else in the same position I did the following

Added a readonly property to the usercontrol so I could determine whether
the usercontrol ispostback was true or false. The ajax I have implemented
always tells me it is a postback.

I then removed the code from the dropdownlist_slectedindexchanged event and
stuck it in page load when a postback was true so the viewstate information
was pulled through.

TA

"steven scaife" wrote:

> Hi
>
> I have been banging my head for a few days now with this issue.
>
> I have a page that has several update panels everything is working fine
> except for 1 thing.
>
> I am creating a sort of wizard that will build a form that I plan to save to
> a database
> On stage 2 I load a usercontrol an unspecified number of times depending on
> how many fields there will be and add it to an accordian pane.
>
> So if I have two fields there will be two accordian panes this all works fine
>
> Inside of the usercontrol there is a drop down list that adds textboxes
> and/or dropdown lists to a placeholder.
>
> When I postback the fields in the usercontrol maintain postback and the
> dropdown list has the value selected however the dynamically created controls
> appear but don't have any values that have been selected or entered into them.
>
> All the controls have the same ids so thats not the problem.
>
> The page on the load loops through and calls loadcontrol sets the id and
> adds the control to the accordianpane which is added to the accoridan.
>
> If i have my code in the init event the dropdown value is not preserved
>
> TIA

 
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
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
Usercontrol dynamically loaded (in Init method of webcontrol) have viewstate problems Matt Howeson ASP .Net 0 03-18-2005 09:24 PM
Re: Dynamically Loaded UserControl and ViewState S. Justin Gengo ASP .Net 0 02-17-2004 03:50 PM
Dynamically Loaded Control and ViewState Joey G ASP .Net Web Controls 0 02-17-2004 03:16 PM
maintain viewstate using dynamically loaded server controls Thijs ASP .Net Web Controls 2 12-04-2003 10:03 PM



Advertisments