Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
above code is using in my project. validation in javascript and insert function in code-behind c# language.
It working perfectly on localhost but not working live.
js validation only run but onclick function fire.

What I have tried:

<pre><asp:Button ID="btnSubmit" runat="server" TabIndex="34" Text="Save" CssClass="buttonSave width170" OnClick=" btnSubmit_Click" OnClientClick="return ValidateFunction()"  />


above code is using in my project. validation in javascript and insert function in code-behind c# language.
It working perfectly on localhost but not working live.
js validation only run but onclick function fire.

code copy element below

<input type="submit" name="ctl00$ContentPlaceHolder1$btnSubmit" value="Save" onclick="return ValidateFunction();" id="ContentPlaceHolder1_btnSubmit" tabindex="34" class="buttonSave width170">


code - onclientclick to change onclick

but onclick="btnSubmit_click" is called but changed live.
Posted
Updated 9-Jul-18 2:53am
Comments
Kornfeld Eliyahu Peter 8-Jul-18 8:08am    
Have you tried to debug it to see where it goes on client and server side?
Are you aware of the post-back issue? (AJAX)
Er. Puneet Goel 9-Jul-18 6:23am    
Can you please share like if your ajax is throwing any error. if it's separate JS file, please check if the file is loaded.

1 solution

OnClientClick="return ValidateFunction()


OnClientClick function which we write in javaScript execute on client side before control passed to server and after that
OnClick=" btnSubmit_Click"
executes on the server if your
ValidateFunction()
returns true.

try to debug your javascript validateFunction on server and check what it is returning.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900