I got this approach to call the parent page method from my user control. This "DisplayMessage" function simply accepts the message of the string variable and displays it on the screen. In the user control, I placed a text box and a button. In the button click event, I call the method of the parent page, which we discussed above, using Reflection and passing the value of the text field to the method, and then the method is called and the message is displayed on the screen.
Parent page:
public void DisplayMessage(string message)
{
Response.Write(message);
}
User control:
protected void btnSend_Click(object sender, EventArgs e)
{
this.Page.GetType().InvokeMember("DisplayMessage",System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { txtMessage.Text });
}
It works great for me.
Now I need, I have to call the method that exists in UserControl from its parent page.
Please suggest me. Thanks at Advance.