I have two weird workflows that I’m able to fix.. I fixed them by accident by simply checking a style in ASP.NET code behind. I want to hear your theories as to why this occurs. I have a couple of my own, but I don’t want to have any stereotypes from you reading this if I tell you my theory.
Setup:
So I have a button (event code below in various snippets) on an ASP.NET page that submits my form. There are two workflows that are causing an issue. In each workflow, a WCF service call is being made. The WCF service call sets the CSS visibility attribute to “visible” when it’s invoked. And the response JavaScript function changes the visibility attribute back to “hidden”.
In each of these two workflows, the button that submits my form is being pressed too quickly, and the WCF call never returns, and the WCF service errors out. The form is submitted, and everything is perfect (since the WCF call never changed anything in the form), it’s just that I get the error. A nicer approach to fixing this is to disable the buttons when the WCF service call is happening, which is exactly why I’m making the AJAX spinner visible and hidden. But right now, I am fixing my issue by checking the style, to understand the black boxes of ASP.NET, the browser and JavaScript, and how they’re interacting when ASP.NET checks a style.
When I run this code, I get the WCF error:
Private Sub SaveCancelDeleteButtonClick(ByVal sender As Object, ByVal e As SaveCancelDelete.DynamicButtonEventArgs) Handles SaveCancelDelete.CustomButtonClick
Dim valid As Boolean = ValidatePage()
Trace.Write(String.Format("Caught a button with event {0}", e.EventName))
... continued
When I run this code I DO NOT get the WCF error:
Private Sub SaveCancelDeleteButtonClick(ByVal sender As Object, ByVal e As SaveCancelDelete.DynamicButtonEventArgs) Handles SaveCancelDelete.CustomButtonClick
Dim x As String = ImageAjaxSpinner.Style("visibility")
Dim valid As Boolean = ValidatePage()
Trace.Write(String.Format("Caught a button with event {0}", e.EventName))
... continued
When I run this code I DO NOT get the WCF error:
Private Sub SaveCancelDeleteButtonClick(ByVal sender As Object, ByVal e As SaveCancelDelete.DynamicButtonEventArgs) Handles SaveCancelDelete.CustomButtonClick
If ImageAjaxSpinner.Style("visibility") = "visible" Then
Return
End If
Dim valid As Boolean = ValidatePage()
Trace.Write(String.Format("Caught a button with event {0}", e.EventName))
... continued
When I debug, this style is ALWAYS hidden in these two workflows (in the last 2 snippets obviously since I didn’t have the style code in the first snippet). I have a couple theories, but I want to hear your theories as to why this is happening.
==========
Ideally, I should gray out the buttons during the WCF call, but this is merely a theoretical question.
FYI: The JavaScript is changing the visibility, not the ASP.NET code.
AJAX spinner:
<asp:Image ID="ImageAjaxSpinner" runat="server" ImageUrl="~/images/ajax-spinner.gif" style="position:absolute; top:0px; right:0px; visibility:hidden;" AlternateText="spinner" />
Snippet of JavaScript pseudo class WCF web service error function:
PreAccessioningLoadError: function(sender) {
jQuery(this.Elements.ImageAjaxSpinner).css("visibility", "hidden");
alert("error");
return false;
},
=============
8/24/2011 1:27pm update
When I run this code, I get the WCF error:
Private Sub SaveCancelDeleteButtonClick(ByVal sender As Object, ByVal e As SaveCancelDelete.DynamicButtonEventArgs) Handles SaveCancelDelete.CustomButtonClick
If ImageAjaxSpinner.Visible = True Then
Return
End If
Dim valid As Boolean = ValidatePage()
Trace.Write(String.Format("Caught a button with event {0}", e.EventName))
... continued
When I run this code, I get the WCF error:
Private Sub SaveCancelDeleteButtonClick(ByVal sender As Object, ByVal e As SaveCancelDelete.DynamicButtonEventArgs) Handles SaveCancelDelete.CustomButtonClick
' D-02568 - fixed
'If ImageAjaxSpinner.Style("visibility") = "visible" Then
' Return
'End If
' D-02568 - fixed
'Dim x As String = ImageAjaxSpinner.Style("visibility")
' D-02568 - not fixed; throws WCF error
'If ImageAjaxSpinner.Visible = True Then
' Return
'End If
' D-02568 - not fixed; throws WCF error
Dim x As Boolean = ImageAjaxSpinner.Visible
Dim valid As Boolean = ValidatePage()
Trace.Write(String.Format("Caught a button with event {0}", e.EventName))
... continued
This seems to be a mysterious thing happening in the black box of Mozilla Firefox, and works. It doesn’t work in all browsers, so I didn’t rely on this code at all! Unless a developer of Mozilla Firefox browser can answer my question, I won’t change my answer here. I am disabling my buttons until the WCF service response comes back, so the end-user can’t click the button until the data is there.