[SOLVED] OnClick event not hitting the back end ASP.NET


I have a button that looks like this with both OnClick and OnClientClick events

<asp:Button ID="btnExecute" CssClass="btn btn-primary" runat="server" Text="Execute" OnClientClick="setHiddenValues();" OnClick="Execute_Click"  />

<script type="text/javascript">
    function setHiddenValues() {
    //set some values

EDIT: the code behind looks like this.

protected void Execute_Click(object sender, EventArgs e)
   //execute some code

Now when I click on the ‘Execute’ button, it only seems to go to the javascript and doesn’t hit break points in the backend. It just redirects me to an empty page. There are no errors in js console of the browser’s dev tools and also no errors being thrown in the backend. Network tab in the dev tools shows a 200 but I know the back end is not hit. What am I doing wrong here?


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.

Answered By – Sophonias

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *