views:

108

answers:

1

I create a button control and it shows up, but when clicked event does not fire, not sure if it could be because control gets greated after previous event in AJAX which fires fine.

Should only get executed once.

Any ideas would be appreciated, thanks.

        Button btnCommentSave = new Button();
        btnCommentSave.ID = "mySavebtnComments" ;
        btnCommentSave.Text = "Publish";
        btnCommentSave.BackColor = Color.Aquamarine;
        phBlog.Controls.Add(btnCommentSave);
        btnCommentSave.CommandArgument = row["ID"].ToString();
        btnCommentSave.Click  += new EventHandler(btnSave_Click);

protected void btnSave_Click(object sender, EventArgs e) { other code }

A: 

You are not by any chance executing this code on Page_Load? You have to make sure that this code is executed only once, otherwise the event won't fire.

Zyphrax
Should only get executed once.
BillTetrault
Have you tried to take a look at the final html code? With something like firebug or fiddler?
Zyphrax