I have a button inside UpdatePanel
on my ASP.NET
Page. Here\'s my UpdatePanel
Add ClientIDMode="Static"
on the button
<asp:Button ID="btnPrint" runat="server" OnClick="btnPrint_Click" ToolTip="Click to export report to PDF" Width="100px" Text="Print to PDF" OnClientClick="if(PDFClick()) {return true;} else {alert('2');}" ClientIDMode="Static" />
You can disable the button asynchronously with setTimeout
:
<script type="text/javascript">
function PDFClick(btnPrint) {
btnPrint.value = "Working...";
setTimeout(function() { btnPrint.disabled = true; }, 10);
return true;
};
</script>
The call to document.getElementById
can be removed from PDFClick
by passing a reference to the button element with the this
keyword in OnClientClick
:
OnClientClick="if (PDFClick(this)) { return true; } else { alert('2'); }"