Update panel, wizard control and Javascript crash

Last post 06-10-2007 4:25 AM by orphicfireball. 6 replies.

Sort Posts:

  • Update panel, wizard control and Javascript crash

    08-10-2006, 8:19 AM
    • Member
      10 point Member
    • zebigbuild
    • Member since 08-10-2006, 11:48 AM
    • Belgium
    • Posts 2

    Hi everybody!

    I have an issue with the July CTP. I have a page with an update panel that contains a wizard control, and each wizard step is a web user control. These user controls contains form fields (text boxes, lists, ...) and most of them use validator control to enable the wizard going to next step.

    It works well for the first steps, but i get a javascript error "Microsoft JScript runtime error: 'null' is null or not an object" as soon I reach a step that does not use validator control. Here is the call stack when the error occurs:

       ValidatorGetValue
       CustomValidatorEvaluateIsValid
       ValidatorValidate
       Page_ClientValidate
       WebForm_DoPostBackWithOptions
       JScript - aspnetForm anonymous function

    All of these have "JScript" as language value.

    Going forward (F5), Visual Studio shows me a JavaScript source code related to http://localhost:3464/MyWebSite/WebResource.axd. The crashing function is:

    function ValidatorGetValue(id) {
       var control;
       control = document.getElementById(id);
       if (typeof(control.value) == "string") {    <<<< crash here
          return control.value;
       }
       return ValidatorGetValueRecursive(control);
    }

    ... isn't it some missing "control" null value checking??? ;-)

    Searching for a workaround, it seems clear to me that the exception is due to the fact I do not have a validator on the related wizard step, when there was validators on the preceding steps.

    One solution might be to disable page validation for steps that does not use validators... But I've tried something else: putting a fake textbox and validator on this page... it works, I am now able to move to next step..... but I have now a textbox and a validator I do not need on my page :-)))

    Do you ave another idea to go around this issue?

    Thanks,

    Phil.

  • Re: Update panel, wizard control and Javascript crash

    10-16-2006, 12:01 AM
    • Member
      5 point Member
    • Sindol
    • Member since 10-16-2006, 3:59 AM
    • Posts 1
    I'm having the same exact problem, same exact error message. Removing all the Validators in the wizard solves the problem, as does removing the Atlas update panel. Oddly enough, this error doesn't occur on Firefox, only in IE. Has anyone come up with a fix, I tried adding a control and validator to my steps but all that did was prevent the Next button from working, but the error went away.
  • Re: Update panel, wizard control and Javascript crash

    10-16-2006, 10:48 AM
    • Member
      622 point Member
    • Matt M
    • Member since 08-25-2006, 5:25 PM
    • Eastern WA, USA
    • Posts 128

    If you make the validators group validators, the error will disappear and the wizard will work as expected.

     

    This will work fine:

     

    <asp:TextBox runat="server" ID="AddressLine1TextBox" Width="90%" />
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                ErrorMessage="An address is required." ValidationGroup="page1"
                                                ControlToValidate="AddressLine1TextBox" SetFocusOnError="true" />

      

    While this will crash and burn:

     

    <asp:TextBox runat="server" ID="AddressLine1TextBox" Width="90%" />
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                ErrorMessage="An address is required." ControlToValidate="AddressLine1TextBox" SetFocusOnError="true" />

      

    To make sure they fire as required, modify the ActiveStepChanged or SideBarButtonClick functions.  For example:

     

    Protected Sub NewFormWizard_SideBarButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) _
            Handles NewFormWizard.SideBarButtonClick
    
            If e.NextStepIndex > e.CurrentStepIndex Then
                Validate("page1")
                If Not Page.IsValid() Then
                    e.Cancel = True
                Else
                    ' we need to explicitly set this to false
                    e.Cancel = False
                End If
            End If
        End Sub
      The first IF statement is to allow users to go backwards in the wizard without forcing them to fill out the current page.  Most of the info here was gathered from a post on the forums: http://forums.asp.net/thread/1385194.aspx .
  • Re: Update panel, wizard control and Javascript crash

    01-25-2007, 5:52 PM

    Seemed like a great idea and when I tried it I still received the error message.  I have similar to what others said yet same error.  I have an update panel around a wizard control.  Nothing fancy. Step 1 has required fields, no problem with validation.  Step 2 has validation control.  Error identical to 1st post. 

    Made the validationgroup for the validationsummary and set this in the requiredfieldvalidator control.  Tried what Matt wrote but this didn't work. This is all with the latest release v1.0.

    Anyone have an idea of what may be causing this and a possible solution?

    thanks ^_^ 

    Matt M:

    If you make the validators group validators, the error will disappear and the wizard will work as expected.

     

    This will work fine:

     

    <asp:TextBox runat="server" ID="AddressLine1TextBox" Width="90%" />
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                ErrorMessage="An address is required." ValidationGroup="page1"
                                                ControlToValidate="AddressLine1TextBox" SetFocusOnError="true" />

      

    While this will crash and burn:

     

    <asp:TextBox runat="server" ID="AddressLine1TextBox" Width="90%" />
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                ErrorMessage="An address is required." ControlToValidate="AddressLine1TextBox" SetFocusOnError="true" />

      

    To make sure they fire as required, modify the ActiveStepChanged or SideBarButtonClick functions.  For example:

     

    Protected Sub NewFormWizard_SideBarButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) _
            Handles NewFormWizard.SideBarButtonClick
    
            If e.NextStepIndex > e.CurrentStepIndex Then
                Validate("page1")
                If Not Page.IsValid() Then
                    e.Cancel = True
                Else
                    ' we need to explicitly set this to false
                    e.Cancel = False
                End If
            End If
        End Sub
      The first IF statement is to allow users to go backwards in the wizard without forcing them to fill out the current page.  Most of the info here was gathered from a post on the forums: http://forums.asp.net/thread/1385194.aspx .
  • Re: Update panel, wizard control and Javascript crash

    01-25-2007, 10:19 PM
    • Member
      66 point Member
    • dmose
    • Member since 02-22-2006, 5:27 PM
    • Posts 76

    I had some drama today when I installed 1.0 however there is a fix posted by Scott G today regarding Validation controls inside Updae panels.  I installed the patch and everything is working fine.  FYI I don't put my whole wizard in a panel I have multiple update panels for each wizard step and I also trap the navigate event and check if(!Page.IsValid) property.

    You need to get the Validators.dll and reference it, then add back the Tag mapping to your web.config ..clear you browser history/delete all files etc and go from there.

    http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

    Filed under:
  • Re: Update panel, wizard control and Javascript crash

    01-28-2007, 6:14 PM
    I found out about the validators.dll a couple days ago and this was the solution for my problem as well.  Nice to know that 1.0 was pushed out before the validators DLL was included with an update with windows as mentioned.  Makes you wonder if any place that includes the DLL will stop working once the window update is made available and applied. :)
  • Re: Update panel, wizard control and Javascript crash

    06-10-2007, 4:25 AM

    The official documentation says this, "To make the validators compatible with an UpdatePanel control, set the EnableClientScript property of the validators to false. This disables the client script that would ordinarily be used to perform validation in the browser. As a result, during an asynchronous postback, the validators perform validation on the server. However, because only the content of the UpdatePanel is refreshed, the validators can provide the kind of immediate feedback that is ordinarily provided by client script." (http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx)

    Does this mean there will never be an update?

Page 1 of 1 (7 items)