470,831 Members | 1,373 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,831 developers. It's quick & easy.

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 2826
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bryce Budd | last post: by
5 posts views Thread by John . | last post: by
2 posts views Thread by kieran | last post: by
2 posts views Thread by Joey | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.