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="HidSelected States" type="hidden" runat="server" /><br /><br />
<asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSub mit_Click"
Text="Submit" ValidationGroup ="submitStat es" />
<asp:RequiredFi eldValidator ID="RequiredFie ldValidator1"
ControlToValida te="HidSelected States" runat="server" ErrorMessage="P lease
select the states" ValidationGroup ="submitStat es" />
However, this gives the following error
System.Web.Http Exception: Control 'HidSelectedSta tes' referenced by the
ControlToValida te property of 'RequiredFieldV alidator1' cannot be validated
How can I get around this?
WB. 4 11719
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.W ebControls 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="HidSelected States" 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********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message
news:A4******** *************** ***********@mic rosoft.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="HidSelected States" type="hidden" runat="server" /><br /><br /> <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSub mit_Click" Text="Submit" ValidationGroup ="submitStat es" /> <asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" ControlToValida te="HidSelected States" runat="server" ErrorMessage="P lease select the states" ValidationGroup ="submitStat es" />
However, this gives the following error
System.Web.Http Exception: Control 'HidSelectedSta tes' referenced by the ControlToValida te property of 'RequiredFieldV alidator1' cannot be validated
How can I get around this?
WB.
Hi Nathan,
Thanks for the reply.
Actually the reason I'm using a hidden control is that I have a treeview
with checkboxes of states (eg. California, Oregon etc) for users to select.
This treeview is built by a 3rd party software and the checkboxes are not
server control. So I have a client script to copy the selected boxes value to
the hidden field so that I can use the value on PostBack.
A ListBox won't do 'cuz I need to show the hierachy of countries > states.
Any suggestions?
WB.
"Nathan Sokalski" wrote: 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.W ebControls 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="HidSelected States" 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********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message news:A4******** *************** ***********@mic rosoft.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="HidSelected States" type="hidden" runat="server" /><br /><br /> <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSub mit_Click" Text="Submit" ValidationGroup ="submitStat es" /> <asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" ControlToValida te="HidSelected States" runat="server" ErrorMessage="P lease select the states" ValidationGroup ="submitStat es" />
However, this gives the following error
System.Web.Http Exception: Control 'HidSelectedSta tes' referenced by the ControlToValida te property of 'RequiredFieldV alidator1' cannot be validated
How can I get around this?
WB.
Well, if the control is from a 3rd party, I think you're stuck with either
writing client-side JavaScript to validate it or validating it server-side.
An idea for validating it client-side would be to save in a global variable
what you were trying to save as the hidden field's value. Then add an
onSubmit event that validates and, if it is valid, appends this variable's
value to the URL as a querystring. This will allow you to submit it as if it
were part of the form. It might require a little extra code, but it's the
best I can come up with for a control that you can only access with
JavaScript.
--
Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message
news:F6******** *************** ***********@mic rosoft.com... Hi Nathan,
Thanks for the reply.
Actually the reason I'm using a hidden control is that I have a treeview with checkboxes of states (eg. California, Oregon etc) for users to select. This treeview is built by a 3rd party software and the checkboxes are not server control. So I have a client script to copy the selected boxes value to the hidden field so that I can use the value on PostBack.
A ListBox won't do 'cuz I need to show the hierachy of countries > states.
Any suggestions?
WB.
"Nathan Sokalski" wrote:
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.W ebControls 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="HidSelected States" 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********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message news:A4******** *************** ***********@mic rosoft.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="HidSelected States" type="hidden" runat="server" /><br /><br > /> > <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSub mit_Click" > Text="Submit" ValidationGroup ="submitStat es" /> > <asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" > ControlToValida te="HidSelected States" runat="server" > ErrorMessage="P lease > select the states" ValidationGroup ="submitStat es" /> > > > However, this gives the following error > > System.Web.Http Exception: Control 'HidSelectedSta tes' referenced by the > ControlToValida te property of 'RequiredFieldV alidator1' cannot be > validated > > How can I get around this? > > WB.
Hi,
Thanks for the advice.
I've decided to just user a label control like this:
<asp:Label ID="NoStateSele cted" runat="server" CssClass="error " Text="Please
select states" Visible="False" />
And if no state is selected (ie. empty hidden field), I will turn this
lablel's visible attribute to true and won't process the form...
WB.
"Nathan Sokalski" wrote: Well, if the control is from a 3rd party, I think you're stuck with either writing client-side JavaScript to validate it or validating it server-side. An idea for validating it client-side would be to save in a global variable what you were trying to save as the hidden field's value. Then add an onSubmit event that validates and, if it is valid, appends this variable's value to the URL as a querystring. This will allow you to submit it as if it were part of the form. It might require a little extra code, but it's the best I can come up with for a control that you can only access with JavaScript. -- Nathan Sokalski nj********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message news:F6******** *************** ***********@mic rosoft.com... Hi Nathan,
Thanks for the reply.
Actually the reason I'm using a hidden control is that I have a treeview with checkboxes of states (eg. California, Oregon etc) for users to select. This treeview is built by a 3rd party software and the checkboxes are not server control. So I have a client script to copy the selected boxes value to the hidden field so that I can use the value on PostBack.
A ListBox won't do 'cuz I need to show the hierachy of countries > states.
Any suggestions?
WB.
"Nathan Sokalski" wrote:
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.W ebControls 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="HidSelected States" 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********@hotm ail.com http://www.nathansokalski.com/
"WB" <WB@discussions .microsoft.com> wrote in message news:A4******** *************** ***********@mic rosoft.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="HidSelected States" type="hidden" runat="server" /><br /><br > /> > <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSub mit_Click" > Text="Submit" ValidationGroup ="submitStat es" /> > <asp:RequiredFi eldValidator ID="RequiredFie ldValidator1" > ControlToValida te="HidSelected States" runat="server" > ErrorMessage="P lease > select the states" ValidationGroup ="submitStat es" /> > > > However, this gives the following error > > System.Web.Http Exception: Control 'HidSelectedSta tes' referenced by the > ControlToValida te property of 'RequiredFieldV alidator1' cannot be > validated > > How can I get around this? > > WB. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Randell D. |
last post by:
Folks,
Perhaps someone can figure this out - this is 'the process of my script'
I have a form whereby I can add multiple contacts to a single address.
There is only one firstname/lastname/telephone box - when the user
clicks the add button, I read the values from the form fields and
record them into a hidden text input field. This part works because
during debugging, I have converted the <input type=hidden> into a <input
type=text>...
|
by: BK |
last post by:
I'm having a really strange problem with and HtmlSelect server control
(listbox) and a RequiredFieldValidator that I am trying to use to make sure
that someone has items in the listbox.
The way that the HtmlSelect is populated is via a combination of client-side
javascript and another aspx page (launched by the javascript).
Anyway, everything seems to work just fine in terms of populating the
HtmlSelect. However, when I postback the...
|
by: peshrad |
last post by:
Hi !
I'm using Visual Studio .NET to program a Web application coding in C#.
In my form I use an HtmlSelect control that calls a JavaScript function when
the selected item changes.
This JavaScript function calls the submit() method of the form.
For this HtmlSelect control I have also programmed the ServerChange event,
which is able to dynamically set up the form.
|
by: buran |
last post by:
Dear ASP.NET Programmers,
I am using a CompareValidator control to check the values entered into a
texbox. The textbox is for currencies, so the property Operator is set to
DataTypeCheck and the Type property is set to Currency. However, I would
like to control check whether the user enters a value or not. Do I have to
add an RequiredFieldValidator? Can't CompareValidator handle this?
Thanks in advance,
Burak
|
by: Ed West |
last post by:
Hello,
I have a simple form with some input boxes. After validation if one
fails, then I would like to at the top of the page say something like
"The following fields in red are required" and then change the label in
front of the textbox or dropdown list to red... is this possible with
asp.net? It seems you can only put a RequiredFieldValidator on the
page, and if it fails validation then that text is displayed... ?
Thanks
| |
by: Dave |
last post by:
Hello.
I have the web form where user can input some data in textboxes, I'm
validating user input with RequiredFieldValidator controls, then I have two
buttons "OK" and "Cancel".
Now when I press "OK" the RequiredFieldValidator works fine, but when I
press "Cancel" I don't want to validate inputs.
So how can I temporarily disable RequiredFieldValidator, because I want
press "Cancel" and handle some actions at server side?
|
by: Hongbo |
last post by:
Hi,
I have a Asp.Net written in C#. It serve as information input form. The form encounters sort of
random problem with the email field and state field. I have validator attached with these 2 fields
as the following:
=====
<form id="creditcardform" method="post" runat="server">
Email: <asp:textbox id="txtBillEmail" maxlength="50" width="200" runat="server" />
<asp:requiredfieldvalidator id="vp10" runat="server" initialvalue="" ...
|
by: Giovanni |
last post by:
Dear Friends,
I need your help. I am trying to dynamically create a
RequiredFieldValidator in the ItemCreated event of a DataList but cannot get
it to work. The errors seem to revolve around the .ControlToValidate
property.
When a new Item is created, I check the information coming in from my
database. Based on a field value (TypeID), I create a different control
needed for input: (TextBox, ListBox, DropdownList, etc...), add this...
|
by: dba |
last post by:
using the following code with a problem....
echo "<input type='hidden' name='member_id' value=\"{$row}\">{$row}";
echo "<input type='radio' name='member_name'
value=\"{$row}\">{$row}<br />";
The post_data.php program posts the following
member id is: 0009
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |