S
Steven Cheng[MSFT]
Hi,
From your description, you used a RequiredFieldVadliator on a textbox and
found that when the textbox is set visible = false on serverside. When the
page is submit, the clientside validation not fire ,but the serverside
validation still fire, yes?
I think this behavior is reasonable as Curt has metioned that when the
ASP.NET TextBox's visible is set to false, it won't be renedered out
(<input type="text" ..>) as the html element on the page( you can view the
page source in browser to confirm this). However, the validation control is
not disabled , so it'll still validate both on client and serverside. The
reason why the clientside validation not fire is because the clientside
validtion is using javascript to find the certain htmlelement and validate
the element's value. when textbox visible=false, we can find the html
element in the page's dom collectoin so the validtion not work(but no means
haven't been executed). And at serverside, since the textbox still existing
, so the validation will work as normal. Do you think so?
So if you want to make the validation not be fired (no matter at client or
at server), the correct way is to explicitly set the
RequiredFieldValidator's Enabled property to false when the TextBox(it will
validate) is set to invisible.
IN addition, here is a tech article which has provide detailed description
on the ASP.NET validation controls' infrastructure:
#ASP.NET Validation in Depth
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp?frame=t
rue
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
From your description, you used a RequiredFieldVadliator on a textbox and
found that when the textbox is set visible = false on serverside. When the
page is submit, the clientside validation not fire ,but the serverside
validation still fire, yes?
I think this behavior is reasonable as Curt has metioned that when the
ASP.NET TextBox's visible is set to false, it won't be renedered out
(<input type="text" ..>) as the html element on the page( you can view the
page source in browser to confirm this). However, the validation control is
not disabled , so it'll still validate both on client and serverside. The
reason why the clientside validation not fire is because the clientside
validtion is using javascript to find the certain htmlelement and validate
the element's value. when textbox visible=false, we can find the html
element in the page's dom collectoin so the validtion not work(but no means
haven't been executed). And at serverside, since the textbox still existing
, so the validation will work as normal. Do you think so?
So if you want to make the validation not be fired (no matter at client or
at server), the correct way is to explicitly set the
RequiredFieldValidator's Enabled property to false when the TextBox(it will
validate) is set to invisible.
IN addition, here is a tech article which has provide detailed description
on the ASP.NET validation controls' infrastructure:
#ASP.NET Validation in Depth
http://msdn.microsoft.com/library/en-us/dnaspp/html/aspplusvalid.asp?frame=t
rue
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx