Reputation: 11
I'm using the <asp:LinkButton />
’s OnClick
function on the server side to fetch data. I'm using OnClientClick
to open a popup and populate data. But the page refreshes when I click the button. Please see the attached code and help me to fix the issue.
<asp:LinkButton ID="lnkEdit_Bill" runat="server" CssClass="lnkAddressButton" OnClientClick="javascript:ShowDialog_Both_New('Invoice','edit');" OnClick="lnkEdit_Bill_Click_new" >Edit</asp:LinkButton>
Upvotes: 1
Views: 1327
Reputation: 7969
Bro, if you don't want the postback, just fire the javascript. and you definitely don't need the server control. which you can present your code as below:
<a href="#" onclick="ShowDialog_Both_New('Invoice','edit'); return false;">Edit</a>
Let's says if you still insist want to user ASP.NET server control of LinkButton, then you can do something like this:
<asp:LinkButton ID="lnkEdit_Bill" runat="server" CssClass="lnkAddressButton"
OnClientClick="ShowDialog_Both_New('Invoice','edit'); return false;" >
Edit
</asp:LinkButton>
Upvotes: 1
Reputation: 411
Google event.preventDefault(), I believe i've used that previously to prevent a postback. Also remove the OnClick, if that's not what you want, and just use OnClientClick.
Upvotes: 2