473,511 Members | 16,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically changing the regular expression of Regular Expression validator

VSK
Hi all,

I have a .ascx file with

dropdownbox (SSN, EmpName)
textbox
submit button
regular expression validator( controltovalidate is the above textbox)

Now i want to change the Regular Expression of the validator based on the
dropdownlist item selected.
So i have written the following code in .ascx.cs file

private void ValidateSearchText()
{

if(drpSearchField.SelectedItem.Text == "EmpName")

{

genericRegExpression.ValidationExpression = @"^[A-Za-z\-]+$";

genericRegExpression.ErrorMessage="Please enter only characters for
LastName" ;

}else{

...........................

}

}

This method will be called when the button is clicked.

The problem is that the validator is emitting error mesaage as expected.

Has anyone tried this. Please suggest on this.

Thanks

VSK



Nov 17 '05 #1
2 2934
More experienced folks could hlp you more on this, but
I'd say try dynamically creating the RegularExpressionValidator, and add it
to the Controls collection.

What do you mean
The problem is that the validator is emitting error mesaage as expected. What is the error?

hth
Justin Dutoit

"VSK" <vs*****@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl... Hi all,

I have a .ascx file with

dropdownbox (SSN, EmpName)
textbox
submit button
regular expression validator( controltovalidate is the above textbox)

Now i want to change the Regular Expression of the validator based on the
dropdownlist item selected.
So i have written the following code in .ascx.cs file

private void ValidateSearchText()
{

if(drpSearchField.SelectedItem.Text == "EmpName")

{

genericRegExpression.ValidationExpression = @"^[A-Za-z\-]+$";

genericRegExpression.ErrorMessage="Please enter only characters for
LastName" ;

}else{

...........................

}

}

This method will be called when the button is clicked.

The problem is that the validator is emitting error mesaage as expected.

Has anyone tried this. Please suggest on this.

Thanks

VSK




Nov 17 '05 #2
VSK
sorry abt that...

what i actually meant was it was not showing Error message.(The problem is
that the validator is NOT emitting error mesaage as expected.)

but now i got it working...

thanks for help....

--VSK

"Justin Dutoit" <an**@anon.com> wrote in message
news:Ol**************@TK2MSFTNGP10.phx.gbl...
More experienced folks could hlp you more on this, but
I'd say try dynamically creating the RegularExpressionValidator, and add it to the Controls collection.

What do you mean
The problem is that the validator is emitting error mesaage as expected.

What is the error?

hth
Justin Dutoit

"VSK" <vs*****@hotmail.com> wrote in message
news:ec**************@TK2MSFTNGP12.phx.gbl...
Hi all,

I have a .ascx file with

dropdownbox (SSN, EmpName)
textbox
submit button
regular expression validator( controltovalidate is the above textbox)

Now i want to change the Regular Expression of the validator based on the dropdownlist item selected.
So i have written the following code in .ascx.cs file

private void ValidateSearchText()
{

if(drpSearchField.SelectedItem.Text == "EmpName")

{

genericRegExpression.ValidationExpression = @"^[A-Za-z\-]+$";

genericRegExpression.ErrorMessage="Please enter only characters for
LastName" ;

}else{

...........................

}

}

This method will be called when the button is clicked.

The problem is that the validator is emitting error mesaage as expected.

Has anyone tried this. Please suggest on this.

Thanks

VSK





Nov 17 '05 #3

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

Similar topics

2
18053
by: Bryce Budd | last post by:
Hi all, I am trying to use a regular expression validator to check for the existence of PO Box in an address textbox. The business rule is "No addresses with PO Boxes are allowed." What I...
3
2206
by: Mark | last post by:
To validate the length of a multiline textbox, I'm told that I have to use a regular expression validator. The regular expression below limits it to 25 characters in length, but if the user enters...
2
2242
by: Nazir | last post by:
Hi I'm using a regular expression validator, but if spaces are entered, it bypasses the validation! I'm using ^{5,100}$
2
5561
by: S.Kartikeyan | last post by:
I have the following problem. I am using the follwing Regular Expression validator(REV) with validator expressions ^{1,2}$ ^{3,20}$ The idea of the first exp is 1 or 2 digits the idea of second...
2
9843
by: Dot net work | last post by:
Hello. Say I have a .net textbox that uses a .net regularexpressionvalidator. If the regular expression fails, is it possible to launch a small client side javascript function to do something,...
5
4459
by: John . | last post by:
I am using the Regular Expression Validator control to validate a correct email address. But, at the same time I would like to make it a required field. I tested by using just the regular...
2
1387
by: kieran | last post by:
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...
1
2229
by: vtxr1300 | last post by:
I'm having a problem with a regular expression in conjunction with the regular expression validator. I am trying to make sure that when a user browses for a file to upload, it ends in gif, jpeg or...
2
1817
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters....
0
7242
marktang
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,...
0
7138
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...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7081
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...
0
5668
agi2029
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,...
1
5066
isladogs
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...
0
1576
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 ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
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...

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.