B
Bob
I want to create an aspx page to load different ascx controls to create a
wizard like process, that is, the aspx page has a Continue button, on
initial load, it loads the first ascx control into a placeholder, on
postback, the page's button click event calls a public method on the ascx to
process data, then it removes this ascx, loads the second one, and so on.
Here's the pseudo code of the aspx:
void Page_Load(object sender, EventArgs e) {
if it's not postback - the first time
load ascx 1 into placeholder
else - subsequent postback
load ascx i into placeholder
(ascx i is ascx 1 on first postback, ascx 2 on second postback)
void Button_Click(object sender, EventArgs e) {
if it's the first postback
call ascx1.ProcessData()
remove ascx 1 from placeholder
add ascx 2 to placeholder.
else
call ascx2.ProcessData()
The problem is that the controls inside ascx 2 (e.g. textboxes) are all
empty at call ascx2.ProcessData() even if user entered data. I tracked this
down to the fact that ascx 2 is added to the placeholder in the Button_CLick
event, not in Page_load. This probably messes up its viewstate due to the
event sequence. However I still think my thinking of loading the ascx
controls one by one is a good conceptual design, and wonder if there is a
way to make this work.
Thanks
Bob
wizard like process, that is, the aspx page has a Continue button, on
initial load, it loads the first ascx control into a placeholder, on
postback, the page's button click event calls a public method on the ascx to
process data, then it removes this ascx, loads the second one, and so on.
Here's the pseudo code of the aspx:
void Page_Load(object sender, EventArgs e) {
if it's not postback - the first time
load ascx 1 into placeholder
else - subsequent postback
load ascx i into placeholder
(ascx i is ascx 1 on first postback, ascx 2 on second postback)
void Button_Click(object sender, EventArgs e) {
if it's the first postback
call ascx1.ProcessData()
remove ascx 1 from placeholder
add ascx 2 to placeholder.
else
call ascx2.ProcessData()
The problem is that the controls inside ascx 2 (e.g. textboxes) are all
empty at call ascx2.ProcessData() even if user entered data. I tracked this
down to the fact that ascx 2 is added to the placeholder in the Button_CLick
event, not in Page_load. This probably messes up its viewstate due to the
event sequence. However I still think my thinking of loading the ascx
controls one by one is a good conceptual design, and wonder if there is a
way to make this work.
Thanks
Bob