troubleshooting Question

Button_Click: Execute JavaScript then standard post back

Avatar of DerekWatling
DerekWatlingFlag for South Africa asked on
JavaScriptASP.NETVisual Basic.NET
4 Comments1 Solution551 ViewsLast Modified:
I have my security as part of the Master page with Login/Logout buttons. When a user logs in I want to first execute some JavaScript to disable the button and change the cursor style to "wait" and then PostBack and execute the btnLogin_Click server side code.  So far I have the code below, but need to know which button caused the PostBack so I only execute the code in the "If" statement if btnLogin was clicked and not any other button on the page. Is this the right approach or is there a simpler way to handle this situation?


.aspx
--------------------------------------------------------------------
<asp:Button ID="btnLogin" runat="server" Text="Login" OnClientClick="this.disabled=true;this.value='Wait...';document.body.style.cursor='wait';__doPostBack('btnLogin','');" />
 
.aspx.vb
--------------------------------------------------------------------
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
...
  If IsPostBack Then
    btnLogin_Click(sender, e)
  End If
...
End Sub
 
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
...
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros