473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Validator fails after enabling

I'm trying to dynamically hide/show a HTML table server control.
My form contains one CheckBox control and its AutoPostBack set to true.
The Checked value of this box controls whether to show or hide the table.
Initially this CheckBox is not checked, so the table and all web control it
contains
is not rendered to a client. The table contains several TextBox controls and
each TextBox has a pair of RequiredFieldValidator and CompareValidator.
When I click the previous checkbox, the form postbacks and the server side
code sets HtmlTable.Visible to true. Now all TextBoxes appear at the client
side,
BUT ALL validators indicate failure by showing theirs Text message. Why?
When I do not hide/show the table and it is always visible, the validators
work normally.
This only happens when the table and its content (the textboxes and
validators)
are dynamically showed/rendered. As I know, the CheckBox's AutoPostBack
does not trigger a validation process. Any ideas?
I tried to trace my page and set several breakpoints at Page_Load, PreRender
and
CheckBox_CheckedChanged. At these points I checked values of the IsValid
properties
of the validators. They were always TRUE. I wonder when they switches to
FALSE?
If I'm right, a validator displays the Text only when IsValid is false. Yes?

Nov 20 '05 #1
3 1592
You cannot validate against the CheckBox or CheckBoxList server controls
using the RequiredFieldValidator server control. Instead you need to use the
CustomValidator server control.
Look though :- http://www.syncfusion.com/FAQ/aspnet/WEB_c18c.aspx
Hope that helps
Patrick

"Tumurbaatar S." <sp********@magicnet.mn> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
I'm trying to dynamically hide/show a HTML table server control.
My form contains one CheckBox control and its AutoPostBack set to true.
The Checked value of this box controls whether to show or hide the table.
Initially this CheckBox is not checked, so the table and all web control it contains
is not rendered to a client. The table contains several TextBox controls and each TextBox has a pair of RequiredFieldValidator and CompareValidator.
When I click the previous checkbox, the form postbacks and the server side
code sets HtmlTable.Visible to true. Now all TextBoxes appear at the client side,
BUT ALL validators indicate failure by showing theirs Text message. Why?
When I do not hide/show the table and it is always visible, the validators
work normally.
This only happens when the table and its content (the textboxes and
validators)
are dynamically showed/rendered. As I know, the CheckBox's AutoPostBack
does not trigger a validation process. Any ideas?
I tried to trace my page and set several breakpoints at Page_Load, PreRender and
CheckBox_CheckedChanged. At these points I checked values of the IsValid
properties
of the validators. They were always TRUE. I wonder when they switches to
FALSE?
If I'm right, a validator displays the Text only when IsValid is false. Yes?

Nov 21 '05 #2
I'm sorry. I did not clearly explain the scenario.
There's a HtmlTable with TextBoxes and Validators (Required and Compare).
When the table is visible (I show it by "HtmlTable.Visible = true") and ALL
its rows (where textboxes and validators) are visible too, the validators
work
normally. When I show the table, but hide SOME rows
(HtmlTable.Rows[i].Visible = false),
then the validators located within visible rows work ok. But in next
roundtrip
I show previously hidden rows (HtmlTable.Rows[i].Visible = true). And the
validators
that were hidden in prior step, appear as FAILED: theirs error texts are
shown.
Though these validators works normally (properly detects blank or invalid
values),
only they initially appears with visible errors. The validators that were
visible already
are not have any problem.
I've done here some more tests and found that is not related to a validation
process.
Even the validators are disabled (Enabled = false), they re-appears with
visible errors
texts.
I found some workaround, but it does not really solve the problem, only
makes
the problem hidden.
Instead of resetting HtmlTable.Rows[i].Visible properties, I apply CSS
attribute "display" with "none" or "block" values to the rows. In this case,
the hidden rows and controls are rendered to a client, only they are
invisible.
So I need to disable the validators before.
Below is my new method to hide/show rows:

private void ToggleRows(bool Visible)
{
//this is an array of textboxes and validators located in hidden
rows
WebControl[] ctrls =
{
Trans20Txt, Trans20Val1, Trans20Val2,
Trans40Txt, Trans40Val1, Trans40Val2,
Trans00Txt, Trans00Val1, Trans00Val2
};
string display = Visible? "block" : "none";

for (int i = 0; i < ctrls.Length; i++)
ctrls[i].Enabled = Visible;
for (int i = 3; i < FormTbl.Rows.Count - 1; i++)
FormTbl.Rows[i].Style["display"] = display;
}

My old method was shorter and simpler:

private void ToggleRows(bool Visible) // no reason to disable validators
{
for (int i = 3; i < FormTbl.Rows.Count - 1; i++)
FormTbl.Rows[i].Visible = Visible;
}

P.S. The checkbox I mentioned in prior post, I use to as a trigger of
visibility of the table.
"Patrick.O.Ige" <na********@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP14.phx.gbl...
You cannot validate against the CheckBox or CheckBoxList server controls
using the RequiredFieldValidator server control. Instead you need to use
the
CustomValidator server control.
Look though :- http://www.syncfusion.com/FAQ/aspnet/WEB_c18c.aspx
Hope that helps
Patrick

"Tumurbaatar S." <sp********@magicnet.mn> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
I'm trying to dynamically hide/show a HTML table server control.
My form contains one CheckBox control and its AutoPostBack set to true.
The Checked value of this box controls whether to show or hide the table.
Initially this CheckBox is not checked, so the table and all web control

it
contains
is not rendered to a client. The table contains several TextBox controls

and
each TextBox has a pair of RequiredFieldValidator and CompareValidator.
When I click the previous checkbox, the form postbacks and the server
side
code sets HtmlTable.Visible to true. Now all TextBoxes appear at the

client
side,
BUT ALL validators indicate failure by showing theirs Text message. Why?
When I do not hide/show the table and it is always visible, the
validators
work normally.
This only happens when the table and its content (the textboxes and
validators)
are dynamically showed/rendered. As I know, the CheckBox's AutoPostBack
does not trigger a validation process. Any ideas?
I tried to trace my page and set several breakpoints at Page_Load,

PreRender
and
CheckBox_CheckedChanged. At these points I checked values of the IsValid
properties
of the validators. They were always TRUE. I wonder when they switches to
FALSE?
If I'm right, a validator displays the Text only when IsValid is false.

Yes?




Nov 21 '05 #3
When a Validator's IsValid property is false at the time of Render, it
writes out its error message. A call to Page.Validate() will update IsValid
on each validator. That call should happen before OnPreRender, so if IsValid
is true while debugging PreRender, we must look for another cause.

When validators output themselves, they are always a <span> tag containing
the error message. To keep them initially hidden, they include
style="visibility:hidden" (when Display="Static") or
style="visibility:hidden;display:none" (when Display="Dynamic"). I am
wondering if your HTML includes this style or not. In any case, look
carefully at the HTML generated to try to locate the source of it becoming
visible. There may be a style sheet problem.
--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Tumurbaatar S." <sp********@magicnet.mn> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
I'm trying to dynamically hide/show a HTML table server control.
My form contains one CheckBox control and its AutoPostBack set to true.
The Checked value of this box controls whether to show or hide the table.
Initially this CheckBox is not checked, so the table and all web control
it contains
is not rendered to a client. The table contains several TextBox controls
and
each TextBox has a pair of RequiredFieldValidator and CompareValidator.
When I click the previous checkbox, the form postbacks and the server side
code sets HtmlTable.Visible to true. Now all TextBoxes appear at the
client side,
BUT ALL validators indicate failure by showing theirs Text message. Why?
When I do not hide/show the table and it is always visible, the validators
work normally.
This only happens when the table and its content (the textboxes and
validators)
are dynamically showed/rendered. As I know, the CheckBox's AutoPostBack
does not trigger a validation process. Any ideas?
I tried to trace my page and set several breakpoints at Page_Load,
PreRender and
CheckBox_CheckedChanged. At these points I checked values of the IsValid
properties
of the validators. They were always TRUE. I wonder when they switches to
FALSE?
If I'm right, a validator displays the Text only when IsValid is false.
Yes?


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
by: Nick Kew | last post by:
There's a new beta of the W3C Markup Validation Service now live at <URL:http://validator.w3.org:8001/> Probably the most important change is verbose output, including attempts to explain the...
2
by: Dot net work | last post by:
Hello. Say I have a .net textbox that uses a .net regularexpressionvalidator. If the regular expression fails, is it possible to launch a small client side javascript function to do something,...
8
by: News | last post by:
Hi, I have a page with one <form></form>. This page contains 2 part forms with 2 buttons, one for each part form. <form> Part 1 <date>
1
by: Eric Caron | last post by:
Hi everybody, I have a form where I have checkbox that triggers javascript code to make a div appear. This is when the user selects "Other" in the list of choices and we ask him to specify his...
3
by: CK | last post by:
Hello All, I have a page with a text box. It has a required field validator, and a regualur expression validator tied to it. A valid email is required. When clientside is enabled it works...
8
by: Radu | last post by:
Hi. I have an ASP control on my page: <asp:Calendar ID="calStart" ................ Etc </asp:Calendar> and I have a Custom Validator defined as <asp:CustomValidator
9
by: Daniele Perilli | last post by:
Hi everybody, I'd like to introduce you a new little tool I developed to automatically check markup validation of all pages in given websites. It uses W3C HTML Validator and CSS Validator online...
3
by: Andrew Jocelyn | last post by:
Hi I get a JavaScript error with this expression when using the RegExpValidator. Also if I switch off client script the server side code validator finds a match regardless of the entered string....
0
by: teo | last post by:
hallo I'm using vs2005 I set the validator to 'Xhtml transitional 1.0' I notice that the validator fails It doesn't detect some errors and it considers other ones as error but they are not ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.