Rabiya
Rabiya

Reputation: 1

Asp.net button is not firing event

I am having an issue with the asp.net button. It is not firing event. I tried setting causes validation to false and removing the java script and validation but it still doesn't work.

<asp:Button ID="Button2" runat="server" Text="Save" onclick="Button2_Click" />


protected void Button2_Click(object sender, EventArgs e)
{
    std.AddGuardianInfo(
        Convert.ToInt16(DropDownList1.SelectedValue), 
        TextBox6.Text, 
        TextBox7.Text, 
        TextBox8.Text, 
        TextBox9.Text, 
        TextBox10.Text);
    Response.Redirect("Std_FeeInfo.aspx");
}

Upvotes: 0

Views: 385

Answers (2)

Rajeesh Menoth
Rajeesh Menoth

Reputation: 1750

You want to check this steps.

  • @rabiya are you copied this code in some where else ? Then just remove it and double click on your asp button.
  • If you are using updatepanel on onclick event, this may happen.So Use 'EnableEventValidation="false"'

Example :

<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false"  CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

Upvotes: 0

sujith karivelil
sujith karivelil

Reputation: 29006

Change onclick to OnClick in the markup of the asp:button. so the markup will be like this:

<asp:Button ID="Button2" runat="server" Text="Save" OnClick="Button2_Click" />

And an important advise for you: Use css for styling and arranging elements in your page, giving space using a sequence of &nbsp; will not be a good design

Upvotes: 1

Related Questions