Monday, April 8, 2013

how to call method in aspx page from a usercontrol button click event


1. Declare event handler

 public event EventHandler ButtonClick1;

2. enter the method name for the button onclick event in the ascx design markup page.


3. Use that method on the code behind:


protected void btnUpload_Click1(object sender, EventArgs e)
{
     ButtonClick1(sender, e);
}





4.On aspx page use that user control




5. on the page load event of the aspx.cs page call the method to used.


  fileusercontrol1. ButtonClick1 += new EventHandler(CallYourMethod);


 protected void CallYourMethod(object sender, EventArgs e)
{
//your code
}












Protected by Copyscape Duplicate Content Detection Tool

No comments:

Post a Comment