Dynamic asp:Button not firing

Results 1 to 2 of 2

Thread: Dynamic asp:Button not firing

  1. #1
    Join Date
    Dec 1969

    Default Dynamic asp:Button not firing

    I am trying to create a button dynamically in a table cell. I am able to create the button, but when I click on it nothing happens. Here is the code I am using to create the button:<BR><BR><BR>System.Web.UI.WebControls.Butto n cmdInvestigated = new System.Web.UI.WebControls.Button();<BR>cmdInvestig ated.Click += new System.EventHandler(this.cmdInvestigated_Click);<B R>cmdInvestigated.ID ="cmdInvestigated";<BR>cmdInvestigated.Text = "Investigated";<BR>cmdInvestigated.CommandName = "logid";<BR>cmdInvestigated.CommandArgument = member["logid"].ToString();<BR><BR><BR>Here is my event handler code:<BR><BR>private void cmdInvestigated_Click(object sender, System.EventArgs e)<BR>{ <BR> <BR>string cmd = ((Button)sender).CommandArgument.ToString();<BR>st ring test = cmd.ToString();<BR> <BR>}<BR><BR>I would greatly appreciate any help, I have been working on this for hours. Thanks.<BR><BR>

  2. #2

    Default RE: Dynamic asp:Button not firing

    There is a difference between the Click and Command events.<BR>Name and Argument go with the Command which has a different signature.<BR><BR>Try doing the += new eventHandler() after you have added the control to the page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts