ValidatorEnable() causes a 'style' error in WebResource.axd

Rate It (1)

Last post 04-21-2008 11:17 AM by hrmalik. 4 replies.

Sort Posts:

  • ValidatorEnable() causes a 'style' error in WebResource.axd

    04-20-2008, 8:58 AM
    • Loading...
    • hrmalik
    • Joined on 01-05-2007, 10:07 AM
    • Posts 4

    I am trying to disable validation controls from JavaScript using the EnableValidator() method. The controls are within an ASP.NET Panel that can be enabled/disabled by selecting/clearing a checkbox. Following is the function that I have written to control the enabling/disabling of the validation controls.

    function toogleValidationControlsForSource(targetControl, enableStatus){
        var validators = targetControl.getElementsByTagName("span");
        for (counter=0; counter < Page_Validators.length; counter++){
            for (nestedCounter=0; nestedCounter < validators.length; nestedCounter++){            
    // Shortlist validators by excluding any span elements beloging to Label and other controls... if (Page_Validators[counter].id == validators[nestedCounter].id){ ValidatorEnable(String(validators[nestedCounter].id), Boolean(enableStatus)); } } } }
    When I call this function, I receive the following JavaScript error in Internet Explorer: 
    Line: 20
    Char: 5
    Error: 'style' is null or not an object
    This wasted quite some of my time as I was unable to figure out where is it coming from within my code. Using the Firebug utility with Firefox, I have come to know that this error is coming from within 
    WebResource.axd. Following is the detail that Firefox provides:
    val.style has no properties
     
    ValidatorUpdateDisplay("RequiredFieldValidator1")WebResource.axd (line 19)
    ValidatorValidate("RequiredFieldValidator1", undefined, undefined)WebResource.axd (line 215)
    ValidatorEnable("RequiredFieldValidator1", true)WebResource.axd (line 146)
    toogleValidationControlsForSource(div#Panel1, true)WebResource.axd (line 66)
    toogleControlState("Panel1", "Panel", "CheckboxExtender1")WebResource.axd (line 52)
    onclick(click clientX=0, clientY=0)Default.aspx (line 1)
     
    val.style.visibility = val.isvalid ? "hidden" : "visible"; (This is the line 20 in Web.axd that is causing the error)
     
     
    My finding is that this error has something to do with ValidatorEnable(). If I remove or comment this line the error goes away. Can anyone help tell me why am I getting this error and how am I supposed
    to get around with it?
  • Re: ValidatorEnable() causes a 'style' error in WebResource.axd

    04-21-2008, 3:53 AM
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 10:03 AM
    • Posts 1,004
    I think ValidatorEnable() is expecting a reference to the validator element and it looks a little like you're just passing it the id of the validator as a string instead.
    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
  • Re: ValidatorEnable() causes a 'style' error in WebResource.axd

    04-21-2008, 10:23 AM
    • Loading...
    • hrmalik
    • Joined on 01-05-2007, 10:07 AM
    • Posts 4

    I modified the last line to the following i.e. removed String() to stop it from casting the the id. But this did not solve the problem.

    ValidatorEnable(validators[nestedCounter].id, Boolean(enableStatus));

  • Re: ValidatorEnable() causes a 'style' error in WebResource.axd

    04-21-2008, 10:36 AM
    Answer
    • Loading...
    • ramblor
    • Joined on 03-13-2008, 10:03 AM
    • Posts 1,004

    hrmalik:
    ValidatorEnable(validators[nestedCounter].id, Boolean(enableStatus));
     

    That's probably because you're still just passing it the id of the validator and it's expecting a reference to the element itself. Try:

    ValidatorEnable(validators[nestedCounter], Boolean(enableStatus));

    "Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
  • Re: ValidatorEnable() causes a 'style' error in WebResource.axd

    04-21-2008, 11:17 AM
    • Loading...
    • hrmalik
    • Joined on 01-05-2007, 10:07 AM
    • Posts 4

    Great! It solved the problem. Thanks for your help!

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter