moopoo.net
Fishing, technology and anything else

Disable Web Part button after clicking

February 16th, 2010 by Matt

Not sure how, I got to the end point of this so there may be other ways of doing it.
Basically I had a web part the when the button was clicked I needed to disable it.
Adding .Attributes["onclick"] didn’t seem to work, and after trying a few things I managed to get it working this way.
Add the following code into OnPreRender of the web part, assuming cmdGenerate is the name of your button.

cmdGenerate.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(cmdGenerate, "") + ";this.value='Please wait...';this.disabled = true;");

Posted in SharePoint

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.