CausesValidation causes javaScript error

Discussion in 'ASP .Net' started by Don, May 30, 2006.

  1. Don

    Don Guest

    I have a page with several controls on the page and all except one are
    hidden. This page works like a wizard by hiding and showing controls
    has the user clicks next. The control are hidden by setting
    visible=false in the code-behind, so they are never rendered. My next
    button validates the page and on some controls I get the JavaScript
    error below:
    Error: 'undefined' is null or not an object
    Code: 0

    The control that causes this error has another control on it that
    sometimes has visible=false. This is the control that has the
    validators on it. When this inner control has visible=true, and is
    rendered, I don't get the java scrip error. When visible=false I get
    the JavaScript error.

    When the inner control is not rendered, and I get the error, my page
    should not even have any validators on it. What could be causing this
    error?

    I can't 'view source' because the source is always the cached copy with
    the first control visible.


    Thanks,
    Don
    Don, May 30, 2006
    #1
    1. Advertising

  2. Don

    Don Guest

    If I make the problem control be the fist control I don't get the
    problem.
    Don, May 30, 2006
    #2
    1. Advertising

  3. Don

    my$.02 Guest

    Setting visible=false in the code-behind causes the control not to be
    included in the HTML that is sent to the browser, which is why you would get
    a null reference exception in your Javascript. If you need to access the
    control in Javascript but not have the browser display the control, you can
    use the CSS visibility property to hide the control. See
    http://www.w3schools.com/css/pr_class_visibility.asp.
    my$.02, May 30, 2006
    #3
  4. Don

    Don Guest

    My control includes both a text box AND a vlaidator. If I set
    visible=false on the control neither the textBox nor the validator are
    rendered. If the valdiator is not rendered there should be no
    validation and no javascript error. For some reason the causes
    valdiation button always tries to validate even though there are no
    rendered valdiators.
    Don, May 30, 2006
    #4
  5. Don

    my$.02 Guest

    Have you tried setting visible=false on the validators?
    my$.02, May 30, 2006
    #5
  6. Don

    Don Guest

    I tried it but it did not help.
    The validators are on a control that has visible set to false so they
    are not rendered if the control is not rendered. I tried setting them
    to false anyway and it didn't help.

    How can I view the source?
    View Source seems to show the source from the first time the page is
    loaded. The hiding and showing during psotback is never reflected in
    'view source'.
    Don, May 30, 2006
    #6
  7. Don

    Don Guest

    I'll try that. Since they are on an ascx control with visible=false I
    assumed they would not be rendered. I'll explicitly set them to false
    and see if that helps.

    Do you know how I can view the source? When I choose view source I get
    a version for the page with the first control, not the current visiable
    control. It seems that view source is not refreshed on a postback.
    Don, May 30, 2006
    #7
    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. Josh Anderson - remove Zs to reply

    CausesValidation not taking in Repeater control

    Josh Anderson - remove Zs to reply, Nov 20, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    365
    Josh Anderson - remove Zs to reply
    Nov 20, 2003
  2. George Durzi

    CausesValidation of editcommandcolumn

    George Durzi, Feb 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    960
    George Durzi
    Feb 12, 2004
  3. z. f.
    Replies:
    4
    Views:
    1,344
    z. f.
    Jun 23, 2004
  4. Replies:
    2
    Views:
    3,994
  5. Don

    CausesValidation causes javaScript error

    Don, May 30, 2006, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    119
Loading...

Share This Page