I am trying to fire an event, by clicking a button, and it does not fire. The id is
"Update".
Instead of going to the event handling paragraph, code goes to the Page_Load method
and skips the Update_Click method. The event is wired to the Update_Click method.
I have done this before, and never had a problem. (The Update_Click) method is created
by double clicking the button “Update”).
For example –
public partial class WebForm2 : System.Web.UI.Page
{
public string employee;
public decimal employeeDec;
public string empName;
public string date1;
public string date2;
public List<AccessForm> AccessFormList;
// following code skipped
protected void Update_Click(object sender, EventArgs e)
{
AccessFormUpdateDB.UpdateSelectedEmployee(AccessFormList);
}
//code executes here
protected void Page_Load(object sender, EventArgs e)
{
employee = ((TextBox)Page.Pr
There could be several reasons. But the most probable is that your event is not subscribed. You can do it in the markup <asp:Button
runat="server" id="Update" OnClick="Update_Clikck"/> or in code-behind on in
the Init or Page load event:
protected override void OnInit(EventArgs e)
{
Update.Click += Update_Click;
}
Also make sure you don't have anywhere in the code something that overrides event subscription or reinitializes button like Update=new Button();
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C#