473,324 Members | 2,541 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,324 software developers and data experts.

Max Length Custom Control

Does anyone have a good example of a custom validator for max and min length
validation?
Nov 18 '05 #1
4 1578
Rather than creating your own custom control, an easier way would be to just
drop a custom validator control on your page and use it's Server_Validate
event to check the lengths of your strings.

private void vldOrder_ServerValidate( Object source,
ServerValidateEventArgs args)
{
if (txtZip.Text.Length < 5 || txtZip.Text.Length > 9){
args.IsValid = false;
vldOrder.ErrorMessage = "Zip/Postal Code must be between 5 and 9
characters long";
return;
}
}

HTH

"Mike Moore" wrote:
Does anyone have a good example of a custom validator for max and min length
validation?

Nov 18 '05 #2
Mike, I'm curious: Is there any problem with the regular expression I posted
to your question a few days ago? I'd like to do something similar myself, so
am wondering if that breaks down somewhere. To get your "custom control", I'd
think you could derive from regularexpressionvalidator, pass the min and max
lengths, and format the regular expression from there.

Bill

"Mike Moore" wrote:
Does anyone have a good example of a custom validator for max and min length
validation?

Nov 18 '05 #3
Woops, actually there is already a "Range Validator" control in your toolbox
that allows you test the ranges of various data types. This would work just
like the other validation controls where you would have to attach it to a
field on your form.
"ENIZIN" wrote:
Rather than creating your own custom control, an easier way would be to just
drop a custom validator control on your page and use it's Server_Validate
event to check the lengths of your strings.

private void vldOrder_ServerValidate( Object source,
ServerValidateEventArgs args)
{
if (txtZip.Text.Length < 5 || txtZip.Text.Length > 9){
args.IsValid = false;
vldOrder.ErrorMessage = "Zip/Postal Code must be between 5 and 9
characters long";
return;
}
}

HTH

"Mike Moore" wrote:
Does anyone have a good example of a custom validator for max and min length
validation?

Nov 18 '05 #4
no....just trying to find the best way. do you have an example?

"Bill Borg" wrote:
Mike, I'm curious: Is there any problem with the regular expression I posted
to your question a few days ago? I'd like to do something similar myself, so
am wondering if that breaks down somewhere. To get your "custom control", I'd
think you could derive from regularexpressionvalidator, pass the min and max
lengths, and format the regular expression from there.

Bill

"Mike Moore" wrote:
Does anyone have a good example of a custom validator for max and min length
validation?

Nov 18 '05 #5

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

Similar topics

5
by: MLH | last post by:
I'm working with lots of long strings now, it seems. I have to import them & parse them constantly. The A97 memo field type supports only 32768 chars. What happens when this is processed... Dim...
2
by: Abhishek Srivastava | last post by:
Hello All, Can I validate the minimum length of a field using any of the existing validators? I searched google on this subject and found people offering custom controls for this. However,...
4
by: moondaddy | last post by:
Is there a asp.net validator control that validates the length of the text being entered or does everyone just write jscript for this? -- moondaddy@nospam.com
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
1
by: Wannabe_Geek | last post by:
Hi Iam new to MS .Net technology just getting along with it....I created a custom control ,which takes in a query and displays the data in a tabular format....something similar to a datagrid. ...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
4
by: Smokey Grindle | last post by:
What is the best way to write dynamic controls in ASP.NET 2.0?
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.