CustomValidator not working in FireFox

Discussion in 'ASP .Net Web Controls' started by Glen, Jun 27, 2006.

  1. Glen

    Glen Guest

    In ASP.NET 2.0, the validators are not working correctly in FireFox
    (1.5.0.4).

    For example, in the script given to FireFox by WebResource.axd, the function
    IsValidationGroupMatch
    has this:
    if (typeof(control.validationGroup) == "string")

    In FireFox, that does not seem to work. The "expando" property is not
    recognized. Instead, this would work:
    if (typeof(control.attributes["validationgroup"].value) == "string")


    Fixing that does not resolve all the issues however, since other functions,
    like:
    ValidatorValidate
    have code like this:
    if (typeof(val.evaluationfunction) == "function")

    In FireFox, that fails.

    Is there any supported fix for this?
    Thanks,
    Glen
    Glen, Jun 27, 2006
    #1
    1. Advertising

  2. Hi Glen,

    Thank you for your update.

    There were some limitation in ASP.NET 1.1 that prevents custom validator
    from working correctly. As far as I know, the custom validator should work
    in ASP.NET 2.0. Would you please posting some repro code here so that we
    can see the problem more clearly?


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Jun 28, 2006
    #2
    1. Advertising

  3. Glen

    Glen Guest

    I'm not sure what I can do beyond what my initial note had...

    The way I was able to see details was to use Firefox, with the Javascript
    debugger extension (https://addons.mozilla.org/firefox/216/). Build a simple
    ..NET 2.0 page that has some validation controls on it. Test, and you will
    see that validation does not work.

    When tracing in the debugger, you can see that the expando properties are
    not recognized, though they do exist in the "attributes" collection.

    Expando attributes are fine in Firefox, but cannot be accessed as if they
    are a part of the DOM as IE allows. Any attribute that is not part of the
    DOM is only accessible via obj.getAttribute('x') or
    obj.attributes['x'].value.

    The ASP.NET 2.0 client script library needs to be updated to avoid the
    DOM-like property access to expando attributes. Instead, use getAttribute().

    Some links re expandos:
    http://msdn.microsoft.com/library/d...author/dhtml/reference/properties/expando.asp
    http://www.xulplanet.com/ndeakin/archive/2004/9/12/
    http://www.howtocreate.co.uk/tutorials/javascript/dombasics

    Also, all HTML attributes are supposed to be caseless, so <span age="23" />
    and <span Age="23" /> are identical. However IE 6 treats them as two
    different attributes, so be sure that all references are in lowercase!

    Re lowercase attributes:
    HTML4: "in HTML, element and attribute names are case-insensitive"
    (http://www.w3.org/TR/1999/REC-html401-19991224/about.html#h-1.2.1)
    XHTML: "XHTML documents must use lower case for all HTML element and
    attribute names." (http://www.w3.org/TR/xhtml1/#h-4.2)

    Simple example:
    <html>
    <body>
    <div id="abc" age="23" Age="56"></div>
    <script>
    var d = document.getElementById('abc')
    alert(d.id) // okay in both
    alert(d.age) // 23 in IE, undefined in firefox
    alert(d.Age) // 56 in IE, undefined in firefox
    alert(d.attributes['age'].value) // 23 in both
    alert(d.attributes['Age'].value) // 56 in IE, 23 in Firefox
    </script>
    </body>
    </html>

    GLen


    "Walter Wang [MSFT]" <> wrote in message
    news:...
    > Hi Glen,
    >
    > Thank you for your update.
    >
    > There were some limitation in ASP.NET 1.1 that prevents custom validator
    > from working correctly. As far as I know, the custom validator should work
    > in ASP.NET 2.0. Would you please posting some repro code here so that we
    > can see the problem more clearly?
    >
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    Glen, Jun 28, 2006
    #3
  4. Hi Glen,

    Thank you for your update.

    Based on my understanding, the expando property problem should have been
    fixed in current version of ASP.NET 2.0. For example, before Beta2, a
    RequiredFieldValidator renders following HTML when requested by an uplevel
    browser:

    <span
    controltovalidate="text1"
    id="required1"
    evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
    validationgroup="grp1"
    initialvalue=""
    style="color:Red;visibility:hidden;">required</span>

    The controltovalidate, evaluationfunction, validationgroup and initialvalue
    attributes are Expando properties.

    During my test, this has been fixed in current version of ASP.NET 2.0 and
    will render as:

    <span id="required1"
    style="color:Red;visibility:hidden;">required</span>

    <script type="text/javascript">
    <!--
    var required1 = document.all ? document.all["required1"] :
    document.getElementById("required1");
    required1.controltovalidate = "text1";
    required1.errormessage = "required";
    required1.validationGroup = "grp1";
    required1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
    required1.initialvalue = "";
    // -->
    </script>

    As you can see, these attributes such as "validationGroup" are no longer
    defined as expando properties.

    I've done some test using some standard validators and created a simple
    custom validator to test in Firefox and it works correctly.

    Since you're encountering some error when using validators in Firefox, I
    would suggest following possible causes to track down the problem.

    1) ASP.NET 2.0 introduced concept of "ValidationGroup" which can be used in
    3 places:

    * BaseValidator: Use ValidationGroup property to specify which
    validation group this validation control belongs.

    * ValidationSummary: Use ValidationGroup property to specify the name of
    the validation group for which the ValidationSummary control will summarize
    error messages.

    * Controls that will cause postback and have set
    "CausesValidation=true", these controls each have a ValidationGroup
    property that, when set, validates only the validation controls within the
    specified group when the control triggers a post back to the server.

    * System.Web.UI.WebControls.BulletedList
    * System.Web.UI.WebControls.Button
    * System.Web.UI.WebControls.CheckBox
    * System.Web.UI.WebControls.CheckBoxList
    * System.Web.UI.WebControls.DropDownList
    * System.Web.UI.HtmlControls.HtmlButton
    * System.Web.UI.HtmlControls.HtmlInputButton
    * System.Web.UI.HtmlControls.HtmlInputImage
    * System.Web.UI.WebControls.ImageButton
    * System.Web.UI.WebControls.LinkButton
    * System.Web.UI.WebControls.ListBox
    * System.Web.UI.WebControls.RadioButtonList
    * System.Web.UI.WebControls.TextBox

    As you can see, if you have set ValidationGroup for your validators,
    only controls with the same ValidationGroup value will trigger the
    validation of these validators.

    2) ASP.NET 2.0 uses user-agent of browser to determine the browser is
    uplevel or downlevel, you can find browser definition at
    %windir%\Microsoft.NET\Framework\<version>\Config\Browsers. Please verify
    the user-agent that your Firefox browser sending is correct. It should work
    for a default installation of Firefox. During my test, the javascript files
    generated by WebResource.axd are the same from IE or Firefox, you can
    verify this by manually copy the javascript src url to browser address bar
    and save it locally. If they're different, which means probably the browser
    is not recognized correctly.

    3) Is it possible that you're using some Firefox extension that prevents
    the javascript from rendering correctly?

    Hope this helps. Please feel free to post here if anything is unclear.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Jun 29, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad

    CustomValidator not working

    tshad, Nov 11, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    4,554
    tshad
    Nov 12, 2004
  2. Steve Murphy

    CustomValidator Doesn't Run on FireFox

    Steve Murphy, Aug 2, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    4,091
    Peter Blum
    Aug 3, 2005
  3. theresa
    Replies:
    2
    Views:
    721
    theresa
    Sep 12, 2007
  4. J. Cairn

    CustomValidator not working in FormView

    J. Cairn, Sep 16, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    420
    Forum
    Sep 20, 2007
  5. ORF3O
    Replies:
    2
    Views:
    158
    ORF3O
    Oct 14, 2005
Loading...

Share This Page