 |
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

February 2nd, 2005, 02:39 PM
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Loading and Destroying web user controls into a pa
Hello:
Iâve a web form containing a web user control and a panel, this web user control have 2 buttons, when user push 1st button I need load a 2nd web user control into panel of web form. When user push 2nd button of 1st web user control I need destroy 2nd web user control which is into panel and place therein a 3rd web user control.
Iâll appreciate some ideas to attain it.
A.L.
El Hombre que tiene Amigos ha de mostrarse Amigo
__________________
El Hombre que tiene Amigos ha de mostrarse Amigo
|

February 2nd, 2005, 04:35 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Loading controls is easy through Page.LoadControl(path), which is passed to a control reference, then you add through Panel1.Controls.Add(myControl).
You'll probably have to recreate them programmatically on every page load.
Brian
|

February 3rd, 2005, 07:36 PM
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you Brian:
Just I'm having this trouble you explain me.
When I have a web user control loaded which has a button, when user push this button, this web user control simply vanish.
How can I avoid this happens.
Don't you have an example about it?
And how I mantain data into web user control that user already typed?
A.L.
El Hombre que tiene Amigos ha de mostrarse Amigo
|

February 4th, 2005, 09:25 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
No examples, I haven't done what you are doing before. How are you loading the control into the Page? Through the code-behind? Could you post your code so I can see what is happening?
Brian
|

February 4th, 2005, 01:56 PM
|
Authorized User
|
|
Join Date: Dec 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok Brian.
This is code in button of web user control to show next web user control:
private void Button2_Click(object sender, System.EventArgs e)
{
WUC_CreDes.WebForm1 parent1 = (WUC_CreDes.WebForm1) this.Page;
parent1.Button2_Click_1(sender,e);
}
And code into Button2 of web form (Example is a Placeholder):
public void Button2_Click_1(object sender, System.EventArgs e)
{
Example.Controls.Clear();
Control control = this.Page.LoadControl("WebUserControl3.ascx");
Example.Controls.Add(control);
}
In WebUserControl3 I have several TextBox, a button, a label. When user puh button I need to show soemthing into label, but when user push button, this web user control simply vanish.
If I recreate web user control programatically I have not way to recover data into textbox and into label.
El Hombre que tiene Amigos ha de mostrarse Amigo
|

February 4th, 2005, 04:05 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
I guess you aren't using this user control anywhere else? First, you shouldn't invoke a user control in that way (calling the event handler). You should call a method, and the method can do whatever.
I would recommend reading this: http://www.codeproject.com/aspnet/Page_UserControl.asp
You need to recreate the user control on every page load, that's why it vanishes.
Brian
|
|
 |