Dynamic Button OnClick not firing

J

John Harte

Hi,

In the code behind of my ASP.net web page I have code written that is
dynamically creating a button. Here is a sample of how I define it.

//Define Variable
Button btnNext;

public void someMethod()
{
btnNext = new Button();
button += new EventHandler(this.btnNext_Click);
//then i add the control to the page, then call its click event
btnNext_Click();
}

When I clickthis button on the page, the page postsback and its onclick
event is never called (stepping through the code shows that it never gets
reached). If I click the button a second time, the method is called and it
works fine.

Im not sure if there is any more information I can give, and help would be
greatly appreciated

John Harte
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top