Home All Groups Group Topic Archive Search About

Regular Expressions Problem

Author
20 Mar 2006 4:25 PM
kieran
Hi,

I am using Visual Studio 2005 and am trying to use a Regular Expression
Validator control.

I have a drop down list which contains various names, the first one is
"Please Select".  I want the user to have to select a name other than
'Please Select'.

I am thinking maybe the Regular Expression Validator is the best move
for this.  How would i go about telling the Validator that
ddlApprovers.selectedvalue should not equal "Please select".

I have seen articles on writing and compiling your own validators...is
this the only way to do this...or is there some quicker way.

I know i can do this server side but i want something to work client
side.


Thanks...

Author
21 Mar 2006 6:22 AM
MS MVP ??? for VB.NET
Dear kieran,

For the Regular Expression Validator, its propose is checking the
expression, ie email address, combination of characters, phone number...etc

For your propose, I think there are 2 types validator fits your need.
1) Custom Validator
2) CompareValidator.

As you said, you don't want to use Custom one, so you may try to use Compare
Validator. Just compare the value if it is equal to "Please Select", if it
does, erturn false.


--
Hope this help and welcome to reply the testing result.

Regards
Ken Lin, Kam Hung
Founder and VP of Hong Kong .NET User Group(http://HKNetUG.com)
MCP, MCP+I, MCDST, MCSA, MCSE(NT4 & win2k),
MCSE+I, MCDBA(SQL7 & SQL2K), MCSD(VB6 & .NET), MCAD(.NET)
Microsoft Community Star(Hong Kong & Taiwan)
Microsoft Most Valuable Professional(.NET since 2003)
MCT2004 & 2005



Show quoteHide quote
"kieran" <kieran5***@hotmail.com> wrote in message
news:1142871927.187429.30910@g10g2000cwb.googlegroups.com...
> Hi,
>
> I am using Visual Studio 2005 and am trying to use a Regular Expression
> Validator control.
>
> I have a drop down list which contains various names, the first one is
> "Please Select".  I want the user to have to select a name other than
> 'Please Select'.
>
> I am thinking maybe the Regular Expression Validator is the best move
> for this.  How would i go about telling the Validator that
> ddlApprovers.selectedvalue should not equal "Please select".
>
> I have seen articles on writing and compiling your own validators...is
> this the only way to do this...or is there some quicker way.
>
> I know i can do this server side but i want something to work client
> side.
>
>
> Thanks...
>
Author
21 Mar 2006 9:45 AM
Cerebrus
Hi kieran,

I'm not familiar with VS 2005, but in VS 2003, a Validator control had
an InitialValue property that allowed you to set the Initial text that
would display in a control (in your case, a DropDownList ). This was
ideal to set the Initial text to something like :"Please select"

Using this along a RequiredFieldValidator, the Validator would fail
only if the selected value remains "Please select".

I don't know if this behaviour is the same in VS 2005, but you can
check it out.

http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.requiredfieldvalidator.initialvalue.aspx

Regards,

Cerebrus.