user3617749
user3617749

Reputation: 1

asp.net button click not working

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

Answers (4)

Hack Dawg
Hack Dawg

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

Nasira Mohamed Noufal
Nasira Mohamed Noufal

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

KJ Price
KJ Price

Reputation: 5964

replace

OnClick="loginbtn_Click"

with

OnClick="loginbtn_Click()"

Upvotes: -1

suff trek
suff trek

Reputation: 39767

Because you have return false in your OnClientClick. Remove it an the button will post back.

Upvotes: 2

Related Questions