How to send a label from a WebUserControl embedded into a Web Form to a text box insi

see07

Regular
Joined
Apr 16, 2004
Messages
78
Location
Mexico City
Hello everybody…

I have a WebUserControl embedded into a Web Form.

When user clicks a button in the WebUserControl I launch this code:

((WUC_WF.WebForm1) this.Parent).TextBox1.Text = this.Label1.Text;
Where:
WUC_WF = my project name.
WebForm1 = the web form where is embedded the WebUserControl.
TextBox1 = the text box into web form where I want to send the label Label1.
Label1 = the label in WebUserControl that I want to send to TextBox1.

When I run the project, an error is displayed "Server error in application, exception not controlled".
Into web form I have:
public System.Web.UI.WebControls.TextBox TextBox1;
What is wrong with this?

I’ll thank some suggestions about this.
A.L.
 
Last edited:
Finally I got the solution

In WebUserControl button I put:

WUC_WF.WebForm1 parent = (WUC_WF.WebForm1) this.Page;
parent.TextBox1.Text = this.Label1.Text;


Inside the Web Form I put:

public System.Web.UI.WebControls.TextBox TextBox1;
 
Back
Top