Calling Javascript Function On Onclientclick Event Of A Submit Button
In my asp.net page, I have three text boxes and one button. First two text boxes are being used to get the value from the user and third one is being used to show the sum of first
Solution 1:
OnClientClick="SomeMethod()"
event of that BUTTON, it return by default "true
" so after that function it do postback
for solution use
//use this code in BUTTON ==> OnClientClick="return SomeMethod();"//and your function like this
<script type="text/javascript">
function SomeMethod(){
// put your code here returnfalse;
}
</script>
Solution 2:
The above solutions must work. However you can try this one:
OnClientClick="return SomeMethod();return false;"
and remove return statement from the method.
Solution 3:
<asp:ButtonID="btnGet"runat="server"Text="Get"OnClick="btnGet_Click"OnClientClick="retun callMethod();" /><scripttype="text/javascript">functioncallMethod() {
//your logic should be here and make sure your logic code note returing functionreturnfalse;
}
</script>
Post a Comment for "Calling Javascript Function On Onclientclick Event Of A Submit Button"