Saturday 27 August 2016


Submit Once with an ASP.NET Button Server Control With Processing



<asp:Button ID="btnSubmit" runat="server" CssClass="btn-active"  
Text="Submit Data" onclientclick="ClientSideClick(this)"   UseSubmitBehavior="False"
onclick="btnSubmit_Click" Width="120px"/>

<script type="text/javascript">
function ClientSideClick(myButton) {
// Client side validation
if (typeof (Page_ClientValidate) == 'function') {
if (Page_ClientValidate() == false)
{ return false; }
}

//make sure the button is not of type "submit" but "button"
if (myButton.getAttribute('type') == 'button') {
// disable the button
myButton.disabled = true;
myButton.className = "btn-inactive";
myButton.value = "processing...";

//display message
document.getElementById("message-div").style.display = "block";
}
return true;
}
</script>


<script type="text/javascript">
     window.onbeforeunload = function () {
         $("input[type=button], input[type=submit]").attr("disabled", "disabled");
     };
</script>

No comments :