0
votes

i have found lots of example to create a button without postback. However, all fail in my case, so can you check it?

    <asp:Button ID="btnNew" CssClass="btnNew btn" runat="server" Text="New" OnClientClick="showDiv(); return false;" />
    <button id="btnNew" class="btnNew " onclick="showDiv();">New</button>
    //jQuery function => $("#btn").Click();

For this button, i won't use it in server, so it should be a pure html button..

Can anyone tell me what's wrong of above code?

2
If you debug your code do you see any errors in your console? - Lajos Arpad

2 Answers

1
votes

If you don't want to call server side function simply add input type='button'

<button type="button" id="btnNew" class="btnNew" onclick="showDiv();">New</button>

OR

<input type="button" id="btnNew" class="btnNew " value="New" onclick="showDiv();" />
0
votes

Letting the function "showDiv" return "false" should do the trick.

function showDiv() {
   [your code]
   return false;
}