Preventing a LinkButton from Posting Twice During a Double Click

Apperently, you can’t count on the users not double-clicking on a link. I found this during a Google search and it seems to be working fine.

protected void Page_Load(object sender, EventArgs e)
{
     this.LinkButton1.Attributes.Add("onclick", "this.disabled=true;"  +
           ClientScript.GetPostBackEventReference(this.LinkButton1, ""));
}

This disabled the link on the first click, then postbacks the form via the __doPostBack Javascript method ASP.Net creates.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Reddit
  • DotNetKicks
  • Technorati
  • TwitThis

Leave a Reply