Hi All,
I'm having problems getting a custom validator to work. I'm hoping someone
could perhaps notice what I've missed. I only want to provide a server side
validation method. The problem is basically that the method that I've designated
as the validation routine never gets called so I can't do anything about
potentially duff data.
I've declared the custom control as:
<asp:customvali dator id=valDoB runat="server" controltovalida te="txtDoB"
errormessage="P lease ensure a valid date has been provided in the DoB field"
onservervalidat e="valDoB_Serve rValidate" EnableClientScr ipt="False">*</asp:customvalid ator>
Then I have a method called valDob_ServerVa lidate
public void valDoB_ServerVa lidate(object source, System.Web.UI.W ebControls.Serv erValidateEvent Args
args) {
if(txtDoB.Text == String.Empty){
valDoB.ErrorMes sage = "Please ensure that the DoB field has been filled
in";
}
}
If anyone can spot what I've missed I would be very greatful
Thanks all
tce 2 1643
Couple things.
If you use an inner text and and error message, it won't work quite the
same. Stick with one or the other, unless you are using a summary
validator.
The CustomValidator will NOT call your validation method if the textbox is
empty. You will need to use a RequiredFieldVa lidator for this.
You validate method should look something like this. The args.IsValid
property actually determines whether validation fails for the page. It is
true by default, so you must make it false.
validate( .. )
{
if ( args.Value != "hello" )
args.IsValid = false;
}
HTH,
bill
"SimonH" <no**@hotmail.c om> wrote in message
news:34******** *************@n ews.microsoft.c om... Hi All,
I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server
side validation method. The problem is basically that the method that I've
designated as the validation routine never gets called so I can't do anything about potentially duff data.
I've declared the custom control as:
<asp:customvali dator id=valDoB runat="server" controltovalida te="txtDoB" errormessage="P lease ensure a valid date has been provided in the DoB
field" onservervalidat e="valDoB_Serve rValidate"
EnableClientScr ipt="False">*</asp:customvalid ator> Then I have a method called valDob_ServerVa lidate
public void valDoB_ServerVa lidate(object source,
System.Web.UI.W ebControls.Serv erValidateEvent Args args) { if(txtDoB.Text == String.Empty){ valDoB.ErrorMes sage = "Please ensure that the DoB field has been filled in"; } }
If anyone can spot what I've missed I would be very greatful
Thanks all
tce
Hi Bill
Thanks for your reply. I'm not sure why but I went home last night with it
broken and then it started working on the first new build this morning.
Havent a clue why.
The info you've provided is helpful though so thank you
Simon Couple things.
If you use an inner text and and error message, it won't work quite the same. Stick with one or the other, unless you are using a summary validator.
The CustomValidator will NOT call your validation method if the textbox is empty. You will need to use a RequiredFieldVa lidator for this.
You validate method should look something like this. The args.IsValid property actually determines whether validation fails for the page. It is true by default, so you must make it false.
validate( .. ) { if ( args.Value != "hello" ) args.IsValid = false; } HTH,
bill "SimonH" <no**@hotmail.c om> wrote in message news:34******** *************@n ews.microsoft.c om... Hi All,
I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server side
validation method. The problem is basically that the method that I've designated
as the validation routine never gets called so I can't do anything about potentially duff data.
I've declared the custom control as:
<asp:customvali dator id=valDoB runat="server" controltovalida te="txtDoB" errormessage="P lease ensure a valid date has been provided in the DoB field"
onservervalidat e="valDoB_Serve rValidate" EnableClientScr ipt="False">*</asp:customvalid ator>
Then I have a method called valDob_ServerVa lidate
public void valDoB_ServerVa lidate(object source, System.Web.UI.W ebControls.Serv erValidateEvent Args
args) { if(txtDoB.Text == String.Empty){ valDoB.ErrorMes sage = "Please ensure that the DoB field has been filled in"; } } If anyone can spot what I've missed I would be very greatful
Thanks all
tce This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Spartanicus |
last post by:
The document at http://homepage.ntlworld.com/spartanicus/custom_dtd.htm
uses a custom DTD, the w3c validator validates it but with this warning:
"Unknown Parse Mode!
The MIME Media Type (text/html) for this document is used to serve both
SGML and XML based documents, and it is not possible to disambiguate it
based on the DOCTYPE Declaration in your document. Parsing will continue
in SGML mode."...
|
by: Evgueni |
last post by:
Hello,
I am new to .NET, and a custom validator is giving me a lot of grief.
I want to use a Custom Validation control and for some reasons it's not firing the validation procedure. I am using .NET framework 1.0
Here is the declaration of the control
<asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 103; LEFT: 304px; POSITION: absolute; TOP: 408px" runat="server" ErrorMessage="Bad input -- please correct"...
|
by: Vinod I |
last post by:
Hi Team,
I made a custom validator control which is having 2 public properties. But
after making dll & adding that to the ToolBox, I could not able to find
these properties in Property Box.
Can any body explain me where am I wrong ? Also, if I want to make this
control as like other validator control, e.g. to skip the "Registering on
the Page", wat should I do ?
|
by: pmud |
last post by:
Hi,
I am using a compare validator in asp.net application(c# code). This Custom
validator is used for comparing a value enterd by the user against the
primary key in the SQL database. IF the VALUE ENTERED BY THE USER EXISTS IN
THE DB , then THE ERROR MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/default.asp?url=/library/en-...
|
by: Mattyw |
last post by:
Hi,
I'm relatively new to Web Forms, I have been using Required Field
Validators and Regular Expression Validators on a Web Form I am
developing and everything works as expected using Visual Studio.NET
2003 and VB code behind.
I have a radio button and textbox, and basically i need the textbox to
be required based on the user selecting "Yes" from the radio button.
I've read through the newsgroups and found that a Custom Validator
| |
by: Alan Silver |
last post by:
Hello,
I have a custom validator on my page, and have the server-side code
working fine. I want to add a client-side funtion as well, but am not
sure how to wire it in so that it works with the other validators on the
page.
I specified the name of the Javascript function with the
ClientValidationFunction attribute of the custom validator, and it is
being called fine. However, if the validator returns false (ie bad
|
by: Andy |
last post by:
Hi folks,
I have a customvalidator control that works properly if it isn't
contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I
find that _ServerValidate doesn't get fired, even if I force the
customvalidator to validate by invoking its validate() method after a
button is clicked:
cvCustomValidator_ServerValidate(object source,
system.Web.UI.WebControls.ServerValidateEventArgs args) <== doesn't get
|
by: Rick |
last post by:
Hello,
I built a composite web control that has a textbox and a date
control.
added my custom control on a webform where there are other standard
controls.
Each control on the form has a required validator.
I need to have a validator for my custom control, but don't know how
to do this.
I added a CustomValidator to the form, but in design mode, my custom
|
by: gagandeepgupta16 |
last post by:
Hi
I am working on an entry form using validation controls in ASP.NET.
I have two controls which requires custom validators, no issue in using plain custom validators.
But when i am using Validation Callout Extender with the custom validators its not working properly.
here is the link where i got solution for one custom validator with validation callout extender :-
http://www.junnark.com/Articles/Article0001.aspx
I searched a lot but...
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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: 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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |