how to caputure user control button click event in aspx page

 Posted by Kamlesh420 on 12/10/2011 | Category: ASP.NET Interview questions | Views: 2818 | Points: 40
Answer:

in ascx page


using System;

using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
public event EventHandler obj;


public string st
{
get
{
return this.TextBox1.Text;
}

}
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
obj(sender, e);
}
}



In aspx page


protected void Page_Load(object sender, EventArgs e)

{
WebUserControl1.obj += new EventHandler(Button1_Click);
}

protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = WebUserControl1.st;

}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Kamlesh420