ASPX Code<form...> <!-- Message area to show the user such as when form validation fails --> <asp:Label ID="SubmitMessage" runat="server"></asp:Label> <!-- The submit button of the form --> <asp:Button ID="Submit" Text="Submit" runat="server" /> </form>ASPX Code-Behind Code Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then ' Do something if not a post-back Else ' Do someting if a post-back End If End Sub Private Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click ' Handle the submission of the form End Sub |
ASPX Code<form...> <!-- Message area to show the user such as when form validation fails --> <asp:Label ID="SubmitMessage" runat="server"></asp:Label> <!-- The submit button of the form --> <asp:Button ID="Submit" Text="Submit" runat="server" /> </form>ASPX Code-Behind Code Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then ' Do something if not a post-back Else ' Do someting if a post-back End If |
ASPX Code<script type="text/javascript" language="javascript"> function disableButtonAtSubmit() { /* Unfortunately "SubmitMessage" does not exist */ if (document.getElementById("SubmitMessage")) { document.getElementById("SubmitMessage").style.visibility = "visible"; document.getElementById("SubmitMessage").innerHTML = "Preparing request..."; } /* "Submit" does exist, but you cannot change it */ if (document.getElementById("Submit")) { document.getElementById("Submit").enabled = false; document.getElementById("Submit").style.visibility = "hidden"; document.getElementById("Submit").style.display = "none"; } } </script> <form...> <!-- Message area to show the user such as when form validation fails --> <asp:Label ID="SubmitMessage" runat="server"></asp:Label> <!-- The submit button of the form --> <asp:Button ID="Submit" Text="Submit" runat="server" /> </form>ASPX Code-Behind Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Since we've got a .NET button, in order to add "onclick" to it we have to do it here Submit.Attributes.Add("onclick", "disableButtonAtSubmit()") If Not IsPostBack Then ' Do something if not a post-back Else ' Do someting if a post-back End If End Sub Private Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click ' Disable the button so people cannot continue to click on it Submit.Visible = False thePage.Update() ' Handle the submission of the form End Sub |
ASPX Code<script type="text/javascript" language="javascript"> function disableButtonAtSubmit() { /* Inform the user the submission is being processed until .NET responds */ document.getElementById("SubmitMessageInitial").style.visibility = "visible"; document.getElementById("SubmitMessageInitial").innerHTML = "Processing submission..."; /* Hide the .NET submit button until .NET responds */ document.getElementById("btnContainer").style.display = "none"; } </script> <form...> <!-- Message area to show the user while .NET is processing the submission --> <span id="SubmitMessageInitial" style="color: #ff0000; visibility: hidden;"></span> <!-- Message area to show the user such as when form validation fails --> <asp:Label ID="SubmitMessage" runat="server"></asp:Label> <!-- The submit button of the form --> <div id="btnContainer"> <asp:Button ID="Submit" Text="Submit" runat="server" /> </div> </form>ASPX Code-Behind Code Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Since we've got a .NET button, in order to add "onclick" to it we have to do it here Submit.Attributes.Add("onclick", "disableButtonAtSubmit()") If Not IsPostBack Then ' Do something if not a post-back Else ' Do someting if a post-back End If End Sub Private Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click ' Disable the button so people cannot continue to click on it Submit.Visible = False thePage.Update() ' Handle the submission of the form End Sub |
function disableButtonAtSubmit() { /* Hide the "preCompleted" submit button until .NET responds */ document.getElementById("hideMe").style.display = "none"; /* Submit the .NET form by clicking on the .NET button */ document.getElementById("Completed").click(); } <!-- The submit button the user clicks on, which is initially visible --> <div id="hideMe"> <input type="button" id="preCompleted" value="Submit" onclick="disableButtonAtSubmit()" /> </div> <!-- The .NET submit button of the form, never visible to the user so they cannot click on it --> <div style="visibility:hidden"> <asp:Button ID="Completed" Text="Submit" runat="server" /> </div> |