CausesValidation causes javaScript error

D

Don

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
 
M

my$.02

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.
 
D

Don

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.
 
D

Don

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'.
 
D

Don

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top