1

I've created an ASP.NET button like so:

<asp:Button ID="btnSaveCoords" runat="server" OnClick="btnSaveCoords_Click" Text="Save Changes" CssClass="btn btn-warning" />

and the event in the OnClick is defined as follows:

protected void btnSaveCoords_Click(object sender, EventArgs 
{
    System.Diagnostics.Debug.WriteLine("Saving Coordinates...");
}

When I click the button, btnSaveCoords_Click isn't fired. What am I doing wrong?

4
  • 2
    btnSaveCoords_Click != btnSaveCrop_Click Commented Aug 6, 2014 at 20:00
  • OnClick="btnSaveCoords_Click" should be OnClick="btnSaveCrop_Click" Commented Aug 6, 2014 at 20:01
  • Typo in copying code, fixed. Commented Aug 6, 2014 at 20:05
  • Do you have any message in browser console? Commented Aug 6, 2014 at 20:06

1 Answer 1

2

The firs row in the .aspx markup file should be like this:

<%@ Page Language="C#" AutoEventWireup="true" 
CodeBehind="WebForm1.aspx.cs" Inherits="SportStore.Views.WebForm1" %>
Sign up to request clarification or add additional context in comments.

2 Comments

Yes all of that seems in order.
And are you using any JS library, Ajax...? Is Page_Load event working?? Here is an article from post back in ASP: c-sharpcorner.com/uploadfile/2f73dd/what-is-postback-in-Asp-Net read it and try to find out what are in two two hidden fields.

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.