I am attempting to create a button on page load (given specific criteria is met), and add an on click server side event. The button is added to an asp place holder "SaveNew"
My code for creating the button is as follows:
Button btnSave = new Button();
btnSave.ID = "btnSave";
btnSave.Text = "Save and New";
btnSave.BorderColor = System.Drawing.Color.Navy;
btnSave.Height = new Unit("21px");
btnSave.ForeColor = System.Drawing.Color.Navy;
btnSave.Font.Bold = true;
btnSave.Font.Name = "Verdana";
btnSave.Click += new System.EventHandler(save_new);
The button creates the way I would expect, but I do not believe that the event aspect of things is working correctly. When I click on it, the function "save_new" does not fire. It goes through the Page Loading Event but never reaches the save_new event. Does anybody know why this might be or a better way to add a server side onclick event?
Thanks in advance!