I am using the ASP.Net Wizard control to submit a “request”. The wizard has 3 steps.
On step 3 based on the checkboxes the user selects, on step 2, I dynamically display questions pertaining to their selections on step 2. I am dynamically creating labels and text boxes onto step 3 of the wizard.
The problem I am running into is the questions, for the selections on step 2, are not getting rendered on step 3. I am adding the dynamic questions for step 3 in the Page_Init method.
On the wizard active_stepchanged event I grab the user’s checkbox selections and save them into a session variable. However this event occurs after the Page_Init event.
Hi there. Yea dynamic controls can be a bit finicky in regards to postbacks, partial or not.
Regardless, you shouldn't be handling this in the pages init method for this, since the wizard control is an ajax control and should only be making partial postbacks.
create a specific method to respond to on step changed event (as you have already done) for grabbing the selections from step two and store them in viewstate. Then have another method specifically for dynamically creating the controls. In this method, you
would query the viewstate for the data required to determine which controls you need to create and add to the wizard. You might also want to persist some data to the viewstate to indicate which controls were added and their state incase you need to re-create
them.
Hope this helps
When the going get's tough, the tough outsource and take a vacation... lol I wish :(
Regardless, you shouldn't be handling this in the pages init method for this, since the wizard control is an ajax control and should only be making partial postbacks.
Thanks for the reply.
However I am using the standard ASP.Net wizard control and it is making full/normal postbacks. It is not the AJAX version.
BlueTSX
Member
203 Points
144 Posts
Dynamic controls and postback issue
Nov 16, 2012 06:47 PM|LINK
I am using the ASP.Net Wizard control to submit a “request”. The wizard has 3 steps.
On step 3 based on the checkboxes the user selects, on step 2, I dynamically display questions pertaining to their selections on step 2. I am dynamically creating labels and text boxes onto step 3 of the wizard.
The problem I am running into is the questions, for the selections on step 2, are not getting rendered on step 3. I am adding the dynamic questions for step 3 in the Page_Init method.
On the wizard active_stepchanged event I grab the user’s checkbox selections and save them into a session variable. However this event occurs after the Page_Init event.
Any ideas on how I can solve this problem?
magicmike201...
Contributor
2021 Points
481 Posts
Re: Dynamic controls and postback issue
Nov 20, 2012 05:48 AM|LINK
Hi there. Yea dynamic controls can be a bit finicky in regards to postbacks, partial or not.
Regardless, you shouldn't be handling this in the pages init method for this, since the wizard control is an ajax control and should only be making partial postbacks.
create a specific method to respond to on step changed event (as you have already done) for grabbing the selections from step two and store them in viewstate. Then have another method specifically for dynamically creating the controls. In this method, you would query the viewstate for the data required to determine which controls you need to create and add to the wizard. You might also want to persist some data to the viewstate to indicate which controls were added and their state incase you need to re-create them.
Hope this helps
BlueTSX
Member
203 Points
144 Posts
Re: Dynamic controls and postback issue
Nov 20, 2012 02:06 PM|LINK
Thanks for the reply.
However I am using the standard ASP.Net wizard control and it is making full/normal postbacks. It is not the AJAX version.