Reputation: 1
I have a JavaScript code and an asp.net button control , javascript code is working fine but the asp.net button is not working for that js script
<asp:Button ID="loginbtn" CssClass="btn-glow primary login" OnClientClick="abc(); return false;" runat="server" Text="log in" OnClick="loginbtn_Click" />
Upvotes: 0
Views: 176
Reputation: 108
Convert your asp.net button to input button to prevent callback and make an ajax function call.
<input type="button" class="btn-glow primary login" onClick="abc()"/>
function abc(){
//ajax call
}
Upvotes: 0
Reputation: 56
please change the code like this
<asp:Button ID="loginbtn" OnClientClick="abc();" runat="server" Text="log in" OnClick="loginbtn_Click"/>
function abc() {
alert("Hi"); //put your code here
return false;
}
or
function abc() {
alert("Hi"); //put your code here
}
both will work.
Upvotes: 0
Reputation: 5964
replace
OnClick="loginbtn_Click"
with
OnClick="loginbtn_Click()"
Upvotes: -1
Reputation: 39767
Because you have return false
in your OnClientClick
. Remove it an the button will post back.
Upvotes: 2