aspx thread: Adding a Click event for a dynamic Button control..
Am I doing something wrong here? I have one button with the OnClick like so:
--
AddItem.InnerHtml = "<br /><br />Type in a web part number to add as a
related item and click <b>Save</b>:<br />";
TextBox objBox = new TextBox();
objBox.Width = 50;
objBox.MaxLength = 9;
objBox.ID = "AddItem_Box";
AddItem.Controls.Add (objBox);
Button objButton = new Button();
objButton.ID = "AddItem_Button";
objButton.Text = "Save";
objButton.Click += new EventHandler (this.AddItem_Save);
AddItem.Controls.Add (new LiteralControl (" "));
AddItem.Controls.Add (objButton);
AddItem.Visible = true;
--
And then I have the AddItem_Save set up like so:
--
private void AddItem_Save (object sender, System.EventArgs e)
{
this.ErrorMessages.InnerHtml = "You clicked on the Save button.";
}
--
However, it doesn't work. Am I missing something with the EventHandler?
Thank you!
Wells Oliver
Web Applications Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com