I don't think the Validator Controls are capable of validating hidden input
fields. The reason for this is that
1. <input type="hidden"> does not have a corresponding class in the
System.Web.UI.WebControls namespace
2. Because the value attribute can only be modified using code, the value
should be validated before it is assigned to the tag, therefore there is no
need for a validator other than server-side code if the value needs compared
against something the client does not have access to, such as a database
What is your reason for needing a validator for the hidden field? It sounds
like you are just keeping track of what states the user has selected. I
would select doing this using a multiple-selection ListBox like the
following:
<asp:ListBox id="HidSelectedStates" runat="server"
SelectionMode="Multiple"></asp:ListBox>
If you want more suggestions, let me know in more detail what you are doing
with the hidden input. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com http://www.nathansokalski.com/
"WB" <WB@discussions.microsoft.com> wrote in message
news:A4**********************************@microsof t.com...
Hi,
I need to validate a hidden input in my webform to ensure that it's got
value. The controls look something like this:
<input id="HidSelectedStates" type="hidden" runat="server" /><br /><br />
<asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSubmit_Click"
Text="Submit" ValidationGroup="submitStates" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
ControlToValidate="HidSelectedStates" runat="server" ErrorMessage="Please
select the states" ValidationGroup="submitStates" />
However, this gives the following error
System.Web.HttpException: Control 'HidSelectedStates' referenced by the
ControlToValidate property of 'RequiredFieldValidator1' cannot be
validated
How can I get around this?
WB.