I have the following button in an ASP.Net web form:
<asp:Button id="btn_submit" text="Submit (Click only Once)" OnClick="process_form" runat="server" />
In the page code, I have the following function which is used to disable multiple submits (this worked fine under ASP.Net 2.0) ...
private sub prevent_multiple_submits()
dim sb as StringBuilder
sb = New StringBuilder()
sb.Append( "this.value = 'Please wait...';this.disabled = true;" )
sb.Append( Page.ClientScript.GetPostBackEventReference( btn_submit, String.Empty ) )
btn_submit.Attributes.Add( "onclick", sb.ToString() )
end sub
When the page is run under ASP.Net 2.0 the HTML rendered is as follows (worked fine)...
<input type="submit" name="btn_submit" value="Submit (Click only Once)" onclick="this.value = 'Please wait...';this.disabled = true;__doPostBack('btn_submit','');" id="btn_submit" />
When the page is run under ASP.Net 4.0 the HTML rendered is as follows:
<input type="submit" name="btn_submit" value="Submit (Click only Once)" onclick="this.value = 'Please wait...';this.disabled = true;__doPostBack('btn_submit','');" language="javascript" id="btn_submit" />
... and for some reason, the button never appears as disabled ... (like it did under ASP.Net 2.0) ...
The form still submits and everything works -- but the button NEVER APPEARS DISABLED after being clicked on ?!
Has anyone else dealt with this behaviour ?? .. and if so, did you find a solution without resorting to altering web.config, using JQuery, etc.
BTW,
I did find the following references; but nothing has worked yet for me under ASP.Net 4.0.
ASP.NET, javascript: silly annoying apostrophe problem
HTMLEncode/HTMLDecode and the apostrophe ASP.net
I guess the question should be how does one add unescaped javascript code to an asp.net button?
Thanks in advance