Carleton_H
asked on
Disable Button in AJAX Panel
I have the following button that I would like to disable when it is clicked:
I'm able to disable all other buttons in AJAX panels with the below script. However, for the button in the code above, it doesn't work (I assume because of the use of the trigger?) This button controls a fileupload control which is why I require a postback. This is the code I use to disable other AJAX buttons (works for all buttons except the one shown above):
Any idea how to make my button disable immediately when clicked?
<asp:UpdatePanel id="uPnlC_Step42_UploadRules" runat="server">
<contenttemplate>
<asp:Button ID="btn_Step42_UploadRules" runat="server" Text="Upload" onclick="btn_Step42_UploadRules_Click" />
</contenttemplate>
<triggers>
<asp:PostBackTrigger ControlID="btn_Step42_UploadRules" />
</triggers>
</asp:UpdatePanel>
I'm able to disable all other buttons in AJAX panels with the below script. However, for the button in the code above, it doesn't work (I assume because of the use of the trigger?) This button controls a fileupload control which is why I require a postback. This is the code I use to disable other AJAX buttons (works for all buttons except the one shown above):
<script language="javascript" type="text/javascript">
var Page;
var postBackElement;
function pageLoad() {
Page = Sys.WebForms.PageRequestManager.getInstance();
Page.add_beginRequest(OnBeginRequest);
Page.add_endRequest(endRequest);
}
function OnBeginRequest(sender, args) {
postBackElement = args.get_postBackElement();
postBackElement.disabled = true;
}
function endRequest(sender, args) {
postBackElement.disabled = false;
}
</script>
Any idea how to make my button disable immediately when clicked?
ASKER
I played around with your solution. It works great at disabling the button, but unfortunately, the onclick="btn_Step42_Upload Rules_Clic k" isn't getting fired when I have the OnClientClick="disableButt on(this);" in there as well. Any ideas?
ASKER
Is it possible to execute the btn_Step42_UploadRules_Cli ck code-behind from the Javascript function you supplied?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, worked like a charm!
Open in new window