dynamic user control properties

C

Chris

novice question here...

I am building a registration form while learning Asp.Net. I am having
trouble passing data between "dynamically"-added server controls.

To simplify, I have a single Registration.aspx page that contains 2
panels. Each panel is loaded with a user control during Page_Load():

protected Panel panel1;
protected Panel panel2;
protected Control regdetails;
protected Control regsummary;

private void Page_Load(object sender, System.EventArgs e){
regdetails = LoadControl("RegDetails.ascx");
regsummary = LoadControl("RegSummary.ascx");
panel1.Controls.Add(regdetails);
panel2.Controls.Add(regsummary);
panel1.Visible=true;
panel2.Visible=false;}

A 'submit' button click event changes which panel is visible. When
the new panel becomes visible, I would like the regsummary user
control's fields (textboxes or labels) to reflect the data entered
into the regdetails control.

I will not go into all the ways I've tried to do this. What I'd like
to know is what is the "correct" way to accomplish something like
this. If someone could just point me in the right direction, suggest
articles, google searches, etc...

btw, I realize my approach to this may be all wrong - maybe I should
just be saving the values some other way (to file, session?) and
loading a new page altogether. My books don't delve into user
controls deeply enough. Anyway, I'm learning...

Thanks,
Chris
 
R

Rocky Moore

Chris said:
novice question here...

I am building a registration form while learning Asp.Net. I am having
trouble passing data between "dynamically"-added server controls.

To simplify, I have a single Registration.aspx page that contains 2
panels. Each panel is loaded with a user control during Page_Load():

protected Panel panel1;
protected Panel panel2;
protected Control regdetails;
protected Control regsummary;

private void Page_Load(object sender, System.EventArgs e){
regdetails = LoadControl("RegDetails.ascx");
regsummary = LoadControl("RegSummary.ascx");
panel1.Controls.Add(regdetails);
panel2.Controls.Add(regsummary);
panel1.Visible=true;
panel2.Visible=false;}

A 'submit' button click event changes which panel is visible. When
the new panel becomes visible, I would like the regsummary user
control's fields (textboxes or labels) to reflect the data entered
into the regdetails control.

I will not go into all the ways I've tried to do this. What I'd like
to know is what is the "correct" way to accomplish something like
this. If someone could just point me in the right direction, suggest
articles, google searches, etc...

btw, I realize my approach to this may be all wrong - maybe I should
just be saving the values some other way (to file, session?) and
loading a new page altogether. My books don't delve into user
controls deeply enough. Anyway, I'm learning...

Thanks,
Chris

I personally, would not bother with hiding/showing different panels, I would
make the data live either in the cache or session data depending on the type
of form, or possibly send it as hidden fields on the page. Could also use
something like my free control to switch the user controls. Might be
overkill in this case however.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top