By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

dynamic user control properties

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Chris" <ch*********@yahoo.com> wrote in message
news:14**************************@posting.google.c om...
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.

--
Rocky Moore
www.HintsAndTips.com - ~ Post Tips and Promote Your Site or Service at No
Charge ~
www.RJSoft.com/Products/RJContentPanel/ - Free web user content control!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.