0

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");
}
3
  • 1
    Please try to add only the relevant part of your code in future questions. Commented Apr 12, 2016 at 10:49
  • 1
    could you please remove the irrelevant codes from your question? and indent the relevant code properly, then you will get better response Commented Apr 12, 2016 at 10:55
  • Try my solution !! This little bit of code we can provide this much of information.!! Commented Apr 12, 2016 at 14:56

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

@Rabiya, define "isn't working". Do you have errors in the browser console? Is the request sent to the server? Do you have an Exception on the server? It isn't working, we understand that. But HOW?
The button is not throwing any exception or error. It is not responding when it is clicked.
0

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" %>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.