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
}
</script>
EDIT: the code behind looks like this.
protected void Execute_Click(object sender, EventArgs e)
{
//execute some code
Response.Redirect("LandingPage");
}
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?
3
Answers
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.
try:
On client click has to return a value of true, else the Onclick will not trigger.
Try configure this in Page element: