ASP.NET Button Onclick Event Not Firing

asp.net Button OnClick event not firing

Have you copied this method from other page/application ? if yes then it will not work, So you need to delete the event and event name assigned to the button then go to design and go to button even properties go to onClick event double click next to it, it will generate event and it automatically assigns event name to the button.
this should work

OnClick Event Not Firing on Button Click ASP.NET

You need to set UseSubmitBehavior to false (default is true):

 <asp:Button ID="DialogWindowButton" runat="server" Text="Save Entry" 
UseSubmitBehavior="False" OnClick="DialogWindowButton_Click" CausesValidation="False" />

From Reference:

Use the UseSubmitBehavior property to specify whether a Button control
uses the client browser's submit mechanism or the ASP.NET postback
mechanism. By default the value of this property is true, causing the
Button control to use the browser's submit mechanism. If you specify
false, the ASP.NET page framework adds client-side script to the page
to post the form to the server.

Button OnClick() Event not Firing

I am willing to bet your button event is firing, but your debugging is not firing. I have seen this when binding the solution to iis incorrectly. In your event, add some code to update a label and I bet it works. Check your URL. I have seen when my IIS binding is incorrect the url changes from localhost:someport to a dns name. This may cause your debugging break points not to fire.

OnClick event not hitting the back end ASP.NET

It turns out my issue was much simpler. The 'Debug' option was not selected. The wiring was correct and it was hitting the backend but I was not able to hit the breakpoints in the backend because I was in Release mode.

ASP.Net Button OnClick not firing up without setting UseSubmitBehavior=false

Okay i think its because you are using required="required" attribute in your code to make certain fields mandatory. When you click the register button it is causing this check validation on all fields so the ones in your modal div as well as the ones in card div. This is why its not getting to your register_onclick event. (the fields username and password or not validated as they are not entered)

You should be able to prove this by removing the required="required" from the password and username textboxes in the modal.

To add validation you could use the asp:RequiredFieldValidator instead of the required attribute for the textboxes etc you want to to make mandatory. see below

https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.requiredfieldvalidator?view=netframework-4.8

You can also add validation groups using so each button only validates certain controls. see below

https://learn.microsoft.com/en-us/previous-versions/aspnet/ms227424(v=vs.100)

Hope this helps. Please let me know if its worked.



Related Topics



Leave a reply



Submit