I got an approach like this to call an Parent Page method from its User Control.This "DisplayMessage" function simply accepts a string variable message and displays it on the screen. In the user control I have placed a textbox and a button. On the click event of the Button I am calling the Parent Page method we discussed above using Reflection and passing the value of the textbox to the method and then the method is invoked 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 fine for me.
Now what I need is, I have to call a method which exists in UserControl from its parent page.
Please suggest me. Thanks in Advance.