<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx</link><description>From Mark Daunt How many times have you seen the problem where somebody clicks on the Submit button a hundred times? One technique to avoid multiple submissions is to use client side script to disable the button after it has been clicked. Problem is you</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1696770</link><pubDate>Fri, 26 Jun 2009 07:17:57 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1696770</guid><dc:creator>amit raut</dc:creator><description>&lt;p&gt;If you have validation group say &amp;#39;Send&amp;#39; on the button, write &lt;/p&gt;
&lt;p&gt;sbValid.Append(&amp;quot;if (Page_ClientValidate(&amp;#39;Send&amp;#39;) == false) { return false; }} &amp;quot;); &lt;/p&gt;
&lt;p&gt;you have to specify validation group name for function Page_ClientValidate.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1696770" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1395942</link><pubDate>Thu, 13 Dec 2007 17:01:50 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1395942</guid><dc:creator>Jportelas</dc:creator><description>&lt;p&gt;Hi there, I came up with this same solution a time ago, it works with .net 1.0 and 1.1, don&amp;#180;t you have something like it with asp.net 2.0?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1395942" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1286433</link><pubDate>Wed, 07 Nov 2007 16:22:03 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1286433</guid><dc:creator>notanguslogan</dc:creator><description>&lt;p&gt;BEAUTIFUL&lt;/p&gt;
&lt;p&gt;thank you, lots of ppl off my back because of this&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1286433" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1243439</link><pubDate>Thu, 11 Oct 2007 21:53:16 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1243439</guid><dc:creator>bn bnbvn</dc:creator><description>&lt;p&gt;Voce ta louco seu porra ?! &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1243439" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1208760</link><pubDate>Fri, 21 Sep 2007 18:55:57 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1208760</guid><dc:creator>Gump</dc:creator><description>&lt;p&gt;Thanks, this is still valuable info even a couple years later!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1208760" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#1204101</link><pubDate>Tue, 18 Sep 2007 12:24:21 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1204101</guid><dc:creator>bill</dc:creator><description>&lt;p&gt;doesn&amp;#39;t work with firefox, at least using ASP.net master pages&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1204101" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#77150</link><pubDate>Wed, 30 Nov 2005 00:55:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:77150</guid><dc:creator>anguslogan</dc:creator><description>a&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=77150" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#75221</link><pubDate>Sat, 12 Nov 2005 18:18:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:75221</guid><dc:creator>anguslogan</dc:creator><description>Just what I was looking for after stuffing around with client-side options, worked like a charm first time. Cheers!&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=75221" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#71503</link><pubDate>Wed, 19 Oct 2005 12:57:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:71503</guid><dc:creator>anguslogan</dc:creator><description>This is great!! Question:  how do you disable all buttons within a page onclick instead of just the current button?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=71503" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#56691</link><pubDate>Fri, 08 Jul 2005 13:30:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:56691</guid><dc:creator>anguslogan</dc:creator><description>Worked Great on a standard aspx form.  Thank you very much.  However, it did not work in a custom control (ascx).  It worked, except it did not cause a post back.  Any ideas?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=56691" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#54304</link><pubDate>Wed, 22 Jun 2005 05:41:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:54304</guid><dc:creator>anguslogan</dc:creator><description>What about client side validation? I want to preform Client-side validation and, if successfull, disable the button and postback. If client-side validation fails, then leave the button enabled.&lt;br&gt;&lt;br&gt;Any ideas or did I miss something in the code above?&lt;br&gt;&lt;br&gt;Thanks,&lt;br&gt;&lt;br&gt;MstrClark&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=54304" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#54303</link><pubDate>Wed, 22 Jun 2005 05:39:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:54303</guid><dc:creator>anguslogan</dc:creator><description>It will work in Vb.Net. Simple make the following changes:&lt;br&gt;&lt;br&gt;sbValid.Append(Me.Page.GetPostBackEventReference(me.cmdMakeNonSupervisor ))&lt;br&gt;&lt;br&gt;-mstrclark&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=54303" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#46778</link><pubDate>Fri, 13 May 2005 12:47:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:46778</guid><dc:creator>anguslogan</dc:creator><description>This code doesn`t work using VB in ASP.Net. The reference to this produces an error: this is not declared.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=46778" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#44876</link><pubDate>Thu, 28 Apr 2005 16:58:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:44876</guid><dc:creator>anguslogan</dc:creator><description>Excellent...works well&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=44876" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#38892</link><pubDate>Fri, 18 Mar 2005 15:03:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:38892</guid><dc:creator>anguslogan</dc:creator><description>I get a &amp;quot;Object not set to an instance of an object&amp;quot; at line &amp;quot;sbValid.Append(&amp;quot;if (typeof(Page_ClientValidate) == 'function') { &amp;quot;);&amp;quot;. &lt;br&gt;&lt;br&gt;Any idea why?&lt;br&gt;&lt;br&gt;Place it in a Page_Load&lt;br&gt;&lt;br&gt;Like&lt;br&gt;void Page_Load(Object Sender, EventArgs e)&lt;br&gt;{&lt;br&gt;System.Text.StringBuilder sbValid = new System.Text.StringBuilder();&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;if (typeof(Page_ClientValidate) == 'function') { &amp;quot;);&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;if (Page_ClientValidate() == false) { return false; }} &amp;quot;);&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;this.value = 'Please wait...';&amp;quot;);&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;this.disabled = true;&amp;quot;);&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;document.all.btnSubmit.disabled = true;&amp;quot;);&lt;br&gt;&lt;br&gt;//GetPostBackEventReference obtains a reference to a client-side script function that causes the server to post back to the page.&lt;br&gt;&lt;br&gt;sbValid.Append(this.Page.GetPostBackEventReference(this.btnSubmit));&lt;br&gt;&lt;br&gt;sbValid.Append(&amp;quot;;&amp;quot;);&lt;br&gt;&lt;br&gt;this.btnSubmit.Attributes.Add(&amp;quot;onclick&amp;quot;, sbValid.ToString());&lt;br&gt;&lt;br&gt;}&lt;br&gt;&amp;lt;form runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br&gt;&amp;lt;asp:Button id=&amp;quot;btnSubmit&amp;quot; text=&amp;quot;whatever&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;&lt;br&gt;&amp;lt;/form&amp;gt;&lt;br&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=38892" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#38584</link><pubDate>Wed, 16 Mar 2005 02:49:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:38584</guid><dc:creator>anguslogan</dc:creator><description>This code worked first time, you need to replace the btnSubmit with the ID of your button, then everything is fine&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=38584" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#38583</link><pubDate>Wed, 16 Mar 2005 02:47:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:38583</guid><dc:creator>anguslogan</dc:creator><description>Excellent Piece of code, exactly what I was looking for, thanks for posting it.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=38583" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#37932</link><pubDate>Wed, 09 Mar 2005 09:47:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:37932</guid><dc:creator>anguslogan</dc:creator><description>This worked except the line for the line of &amp;quot;sbValid.Append(&amp;quot;document.all.btnSubmit.disabled = true;&amp;quot;); &amp;quot;&lt;br&gt;&lt;br&gt;This was causing an error on the page so I committed it out.  I also added a disable button to the post back to keep the button disable (that is what I needed) and this solution worked great.  Thanks for the help.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=37932" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#37201</link><pubDate>Tue, 01 Mar 2005 07:56:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:37201</guid><dc:creator>anguslogan</dc:creator><description>I get a &amp;quot;Object not set to an instance of an object&amp;quot; at line &amp;quot;sbValid.Append(&amp;quot;if (typeof(Page_ClientValidate) == 'function') { &amp;quot;);&amp;quot;.&lt;br&gt;&lt;br&gt;Any idea why?&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=37201" width="1" height="1"&gt;</description></item><item><title>re: Disable Button On PostBack (ASP.NET) - also works with validation controls</title><link>http://msmvps.com/blogs/anguslogan/archive/2004/12/22/27223.aspx#36414</link><pubDate>Sun, 20 Feb 2005 01:51:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:36414</guid><dc:creator>anguslogan</dc:creator><description>re: Disable Button On PostBack&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=36414" width="1" height="1"&gt;</description></item></channel></rss>