Capture Button Event from User Control to Parent Page

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

Ebook Download
View all
Learn
View all