Disable LinkButton on click

Posted on: Tue Jun 30 16:29:42 -0700 2009. Updated on: Tue Jun 30 16:32:27 -0700 2009.
Category: .NET C#

Often we want to make sure a user does not click more than once on a particular function. Usually with things that write to the database or activate payment, we want to control this. You can use the following with a LinkButton or a standart asp.net Button.

protected void Page_Load(object sender, EventArgs e)
{
     LinkButtonSave.Attributes.Add("OnClick", "this.disabled=true; this.onclick=function() { return false;}");
}

Note that this needs to be called from the codebehind, usually page_load works

Comments:

Mon Aug 03 05:44:47 -0700 2009
Thanks! ;)


---------------------------------------------------

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.