Click here to Skip to main content
15,893,644 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am using link button in updatepanel and click on asp:linkbutton it refereshes all page. to stop _dopostback on link button click.

or any alternative to use linkbutton.

Please help.

Thanks
Posted
Updated 7-Sep-15 18:52pm
v2
Comments
[no name] 8-Sep-15 1:07am    
Please provide your aspx code what did you try so far.

1 solution

XML
ASPX code:

<asp:LinkButton ID="someID" runat="server" Text="clicky"></asp:LinkButton>
Code behind:

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        someID.Attributes.Add("onClick", "return false;");
    }
}
What renders as HTML is:

<a onclick="return false;" id="someID" href="javascript:__doPostBack('someID','')">clicky</a>
In this case, what happens is the onclick functionality becomes your validator. If it is false, the "href" link is not executed; however, if it is true the href will get executed. This eliminates your post back.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900