Event is not firing in custon control.
ASP.NET
2
Posts
1
Posters
0
Views
1
Watching
-
Hey, I have created following code. But button event is not firing. Please look at the code and tell me where I am doing wrong.
namespace immu.control
{
[ToolboxData("<{0}:myControl runat=server>")]
public class docControl : WebControl
{public Button btn; protected override void CreateChildControls() { Panel pnl = new Panel(); btn = new Button(); btn.Text = "Click Me"; btn.Click += new EventHandler(btn\_Click); pnl.Controls.Add(btn); this.Controls.Add(pnl); //base.CreateChildControls(); } public void btn\_Click(object sender, EventArgs e) { HttpContext.Current.Response.Redirect("http://google.com"); } }
}
Thanks. Imrankhan
please don't forget to vote on the post that helped you.
-
Hey, I have created following code. But button event is not firing. Please look at the code and tell me where I am doing wrong.
namespace immu.control
{
[ToolboxData("<{0}:myControl runat=server>")]
public class docControl : WebControl
{public Button btn; protected override void CreateChildControls() { Panel pnl = new Panel(); btn = new Button(); btn.Text = "Click Me"; btn.Click += new EventHandler(btn\_Click); pnl.Controls.Add(btn); this.Controls.Add(pnl); //base.CreateChildControls(); } public void btn\_Click(object sender, EventArgs e) { HttpContext.Current.Response.Redirect("http://google.com"); } }
}
Thanks. Imrankhan
please don't forget to vote on the post that helped you.
The problem is solved. Thanks.
please don't forget to vote on the post that helped you.