In User Control cs file:
there is a textbox n a button in user Control
On Button Click we want to display the textbox's text on page which is rendering the user control
protected void Button1_Click(object sender, EventArgs e)
{
this.Page.GetType().InvokeMember("DisplayMessage", System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { TextBox1.Text });
}
In Default.aspx.cs
Drag the user control
public void DisplayMessage(string message)
{
Response.Write(message);
}
Thanks
RajShree Mittal
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Rajshree MittalPosted Sep 22, 2010, 10:30 AM
Hello Mr. Tim Will you plz tell me how would we do the same wid ViewState? As i had tried this n observe that when i was responsing the text written in textbox to get print on aspx page on button click event of UserControl then page_Load of aspx get fire b4 Page_Load of User Control So How could we store its value and let it be shown on Page_Load of .aspx page n BTW........ I had not said that this is the only way to do the same.
Tim ClaasonPosted Sep 16, 2010, 5:00 PM
Couldn't one simply use ViewState?