CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 11/9/2003 1:37:20 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 14 Views: 77 Favorited: 0 Favorite
15 Items, 1 Pages 1 |< << Go >> >|
buzzripper
Asp.Net User
Custom RegularExpressionValidator11/9/2003 1:37:20 PM

0

I'd like to subclass off the RegularExpressionValidator control and add one additional feature: a required field check. The MS regular expression should take care of this, but it doesn't. So I'd simply like to add a design-time property 'Required', and override the validation method and add this additional check in. My problem is: where's the documentation to find the appropriate validation method to override? And what the protected variable names are, for instance to access the ControlToValidate.Text value?

Thanks!

buzz
Kingherc
Asp.Net User
Re: Custom RegularExpressionValidator11/9/2003 4:26:18 PM

0

You don't need to make a control for that. There is no problem in putting two validators for one control. So, you can put a RequiredFieldValidator and a RegularExpressionValidator for the control you want to check. You can link as many validators as you want to a control.

<asp:TextBox id="txtField" runat="server" />
<asp:RequiredFieldValidator ControlToValidate="txtField" Text="The field is empty!" runat="server" />
<asp:RegularExpressionValidator ControlToValidate="txtField" Text="The text is invalid!" ValidationExpression="P[0-9]" runat="server" />
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/9/2003 5:12:30 PM

0

Thanks, but that's the whole point - I don't want to have to put 2 controls on the form. Why should I have to? It really peeves me that the MS regular expression validator doesn't follow regular expressions in this regard. A regex expression can explicitly dictate that the value must be 1 or more characters long, but the MS control allows it anyway. A direct violation of the regular expression, no? Why does it do this? Or am I missing something? If it's just the error message that's the issue, why not just put an 'RequiredFieldErrorMessage' property in there as well so you'd have separate messages?

Anyhow, that's why I'm doing this, I just think it's really clunky to have to put down 2 validator controls for each field.

Thanks for your help!!

buzz
hlaford
Asp.Net User
Re: Custom RegularExpressionValidator11/10/2003 9:10:54 PM

0

you're mixing the concept of format checking and required checking. i say if it works for you, do it.

what i might suggest in your case is making a TextBox that incorporates all of that functionality. then you don't even have to add in the validators. i've done it and it saves a great deal of time in setting up a form. it's surprisingly easy.
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/10/2003 10:32:08 PM

0

Mixing, I guess that's one way to put it, but the fact remains that the regular expression is not followed correctly by the Microsoft control, right? If it was accurately following the regex then it wouldn't allow a blank value when the expression has {1,} in it. That's the only reason why I need a separate required field validator.

That's a great idea of putting it in the TextBox, but how do I keep from having to duplicate all the RegularExpressionValidator functionality?

Thanks!

buzz
hlaford
Asp.Net User
Re: Custom RegularExpressionValidator11/11/2003 1:02:52 AM

0

the MS implementation of the regex check is a bit messed up, but the blank value not eliciting a validation error is logical. that's why the required validator exists. there is a logical difference between format checking and required checking: one does not necessarily require the other. (i don't like that i am defending the MS validators since i think they aren't so great.)

there are really only a few properties you would need to expose (more than likely) in building it all into the textbox. i'd say expose them as you need them. for example, do you really need all the font settings when you can simply set the CssClass? i think i only ever exposed the ValidationExpression and ErrorMessage properties since i was tightly controlling the styles.
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/11/2003 2:30:39 AM

0

I would agree with you if regular expressions didn't already cover the blank/non-blank idea, but they do. There is syntax in regular expressions that specify whether a value can be blank or not. But the MS implementation chooses to ignore this. Not exactly out of character for MS, but wrong nonetheless IMHO :).

Anyhow, I like your idea of the TextBox, but I still don't understand: how do I get the validation functionality? Are you talking about a composite control or something?

buzz
hlaford
Asp.Net User
Re: Custom RegularExpressionValidator11/11/2003 1:29:58 PM

0

the textbox can contain child controls which are your validators. if you concentrate on overriding the existing methods, the whole thing is pretty tidy (as in not too much code). override the CreateControlCollection method to return a new control collection. in CreateChildControls, you add the validators to the TextBox's control collection. i think the next step is overriding the render method to make sure the controls render *after* the input box.

if you get stuck, post a note back here and i'll give you some code snippets.

by your logic, using regular expressions on a non-required field means my expression must now be altered to allow for blanks. they are conceptually two different validations. what you want is a shortcut, which is fine in your case, but is not appropriate for general development. i've built validation frameworks before and they always separate regular expression validation (or any other type) from required field validation.
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/11/2003 10:24:00 PM

0

hlaford -

Child controls, eh? Didn't know you could do that. I'll give that a try, thanks!

Hmm.. not sure why I'm seeing this so different from you (and Microsoft!)...

Absolutely, the regular expression should be altered to allow for blanks! The alternative is that the control violates any regular expression that specifies a non-blank value. And that's what it does now. How are they 'conceptually different' if regular expressions also include the idea of preventing non-blank fields? The idea of non-blank values is fully supported in regular expressions, it's just ignored by this control. To me this is the strange part. I'm not sure why someone would think it shouldn't. Is the thinking that it's an inconvenience to have to work that into the expression, so that the validation string is simpler? Maybe that's what I've been missing. But the fact remains that in doing this the control violates regular expressions. Aren't we programmers? We're not supposed to like exceptions to rules, don't we like consistency and elegance? But here it's just *poof* and we ignore one of the rules of regular expressions...

Don't know why I'm getting so worked up over this stupid issue.... for some reason I find it quite irritating!! But isn't that what these forums are for? :)

Thanks!

buzz

hlaford
Asp.Net User
Re: Custom RegularExpressionValidator11/11/2003 10:57:40 PM

-1

the best way i can think to describe my meaning is that regexes describe a format rather than a presence of a text value. as an example, let's take a textbox that takes a value of a US social security number. the regex i would use is

^\d{3}(-?)\d{2}\1\d{4}$

let's ignore the fact that MS regex validation processing doesn't require the ^ and $ (which is a peeve of mine). if my textbox value isn't required, how do i write that expression?

^(\d{3}(-?)\d{2}\2\d{4})?$

i've just complicated the expression in order to account for that requirement. i cannot now alter the required status of the field without changing the expression i'm using. the first regex defines the format i expect for a SSN; the second is a bastardization of that format to handle a special case that isn't actually a format requirement.

i don't think i'm explaining myself very well here.
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/20/2003 7:43:22 PM

0

Actually you are explaining quite well. I see your point, but I still can't get past the fact that the control ignores part of the regex specification. I understand they have a control dedicated to required fields, but does that mean that they drop support for part of the regular expression specification? Shouldn't I decide whether I want the regex to include/exclude the notion of a blank field? They take that choice right out of my hands and force me to use a 2nd control.

Here's a an analogy: I create a "table-cell-alignment" control. Any time you want to align the contents of a table cell, you need to use my control in a cell. "But", you say, "there's already an HTML spec for alignment in a cell!". To this I say, "too bad, I think it's better for you to use my control so I'm going to ignore the "align" attribute in a <TD> definition".

Might not be a perfect analogy, but conceptually it's the same. They choose to ignore the spec because they have their own approach. As I said before, not exactly out of character for MS, but frustrating! (I happen to respect MS greatly in most things, by the way) This is all academic, of course, I'll survive and use 2 controls, but I do find it an interesting subject for some reason.

buzz
hlaford
Asp.Net User
Re: Custom RegularExpressionValidator11/20/2003 9:14:34 PM

0

well, you could still create your own validator that does what you want. MS isn't preventing it; they just didn't give it to you.
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/21/2003 12:10:56 AM

0

True enough, when I get the time I'll create new control. Or I might buy Peter Blum's validation controls, they're only $50, but it's $50 per application, so gotta think about that one. Thanks for your feedback, hlaford, you got me thinkin' and I appreciate it.
PLBlum
Asp.Net User
Re: Custom RegularExpressionValidator11/21/2003 5:00:28 PM

0

Buzzripper,

You indicated that my Professional Validation And More is $50 per application. That's incorrect. Its $50 per production server, covering all web apps on that server. In addition, I don't charge for development servers. The purchase of one production server license (called a Web Server License) covers all non-production servers. If you have 5 or more production servers, purchase a Site License at $250. If you are building a web app for redistribution, purchase a Redistribution License for $500. It covers your site plus every web app you generate for an unlimited number of customers. I think you'll find this pricing is exceptionally low in this marketplace.
Learn more at http://www.PeterBlum.com/VAM/Home.aspx.
--- Peter Blum
Creator of Professional Validation And More Suite, Peter's Date Package, and Peter's Polling Package
www.PeterBlum.com
buzzripper
Asp.Net User
Re: Custom RegularExpressionValidator11/21/2003 5:57:22 PM

0

I apologize if I mis-characterized your pricing. Each of my apps will go on a different production server (I'm a contractor), so for my purposes it is $50 per app. But if you're running more than one app on a server, you're absolutely correct it is not $50 per app.

Sorry again if I gave the wrong impression. It was not my intention to mislead anyone. In fact, the reason I even mentioned your product was because I have taken a look at your product and like it very much. It's extremely flexible and powerful and I may in fact buy it. I was just thinking aloud, so to speak.

buzz
15 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro ASP.NET 2.0 in VB 2005: special edition. Authors: Laurence Moroney, Matthew MacDonald, Pages: 1360, Published: 2006
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
VB.NET Developer's Guide: Developer's Guide Authors: Cameron Wakefield, Henk-Evert Sonder, Wei Meng Lee, Pages: 784, Published: 2001
Sams Teach Yourself Visual Basic .NET Web Programming in 21 Days Authors: Peter Aitken, Phil Syme, Pages: 544, Published: 2001
Programming ASP.NET: Building Web Applications and Services with ASP.NET 2.0 Authors: Jesse Liberty, Dan Hurwitz, Pages: 930, Published: 2005
Developing . NET Custom Controls and Designers Using C# Authors: James Henry, Pages: 600, Published: 2005
Professional ASP.NET 2.0 Authors: Bill Evjen, Scott Hanselman, Farhan Muhammad, Srinivasa Sivakumar, Devin Rader, Pages: 1253, Published: 2005
Visual Basic .NET Developer's Guide to ASP.NET, XML, and ADO.NET Authors: Jeffrey P. McManus, Chris Kinsman, Pages: 592, Published: 2002
Sams Teach Yourself ADO.NET in 21 Days Authors: Dan Fox, Pages: 656, Published: 2002
Beginning Expression Web Authors: Zak Ruvalcaba, Pages: 474, Published: 2007

Web:
RegularExpressionValidator.AddAttributesToRender Method (System ... The following code example demonstrates how to override the AddAttributesToRender method in a custom server control so that the RegularExpressionValidator ...
RegularExpressionValidator.EvaluateIsValid Method (System.Web.UI ... End If End Sub

Custom RegularExpressionValidator - EvaluateIsValid - VB. ...
Custom RegularExpressionValidator - ASP.NET Forums Re: Custom RegularExpressionValidator. 11-09-2003, 11:26 AM. Contact ... Re: Custom RegularExpressionValidator. 11-09-2003, 12:12 PM ...
SharePoint Custom Field - Regular Expression Validator - Home [en] This project is a custom field for SharePoint 2007 platform including Windows SharePoint Services 3.0 (WSS) and Microsoft Office SharePoint Server 2007 ...
Custom RegularExpressionValidator - ASP.NET Forums Custom RegularExpressionValidator. Last post 09-23-2008 12:39 PM by Yablargo. 15 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
Regular expression validator or custom validation needed : asp.net Can anyone give me a custom validation for asp.net regular expression validator or custom validator, that will validate a textbox so that the numbers 559 ...
SharePoint Custom Field - Regular Expression Validator - Discussions Failed to get value of the "MyField" column from the "Custom Regular Expression Validator" field type control. See details in log. ...
CodeProject: Fire CustomValidator or RegularExpressionValidator ... Override the WebUIValidation.js function to fire the custom or regular expression validator even when the field is empty.; Author: Rooc; Section: Validation ...
Inline script does not resolve in ASP.Net custom control - Stack ... Currently I am working with a custom regular expression validator (unfortunately ). I am trying to set the Regex pattern using a server side inline script ...
Added parameters and regular expression validator : msg#00000 2) I've added a custom Regular _expression_ validator which makes use of the parameter function ... RegularExpressionValidator" txt="Invalid email address! ...







ghosting error with user controls

problem: single instance web control in .net

custom event in user control call event method by name

dhtml menu control like

i want to read controls

property browser in vs with custom control

ddl postback asking for id? but it's there?

add image to control

how? have thmeable url's in custom control.

event/sub is re-running when the web page is refreshed

custome controls, javascript, and firefox/mozilla

how-to: bind custom control to xml

questions for 1and1.com clients only

where to put validators?

read static public property of dynamic user control class

usercontrol maintaining values

how can i add my custom control to appear in validators' control to validate combo box?

i cant set the value of a propety in my user control

pass-through control tag's attributes?

looking for cheap web hosting

dedicated asp.net hosting question

color schemes in server controls

namevaluecollection for a checkbox

page_load in usercontrols

need help with using out parameter

matt fleitz, about your software download

sql server host needed

building xml style custom controls

custom control with multiple properties of collection type

good private label or agent partner reseller sites

   
  Privacy | Contact Us
All Times Are GMT