By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

Validation Groups

P: n/a
asp.net 2/C#/VS2005

Using master pages

I have a page with several text boxes on it. I want to logically group
some of them. So I have a textbox that has required field and regular
expression validators for it. I also have a validation summary on the
page. For each of these four controls, I used the same value for the
"ValidationGroup" property. I have also assigned header text for the
validation summary and error messages for the validators.

But when I run the page, don't enter anything into the text box, and
click an image button (to trigger a postback), nothing happens. No
error message shows.

Is there something else I need to do to make this work?

May 23 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
for each postback control, you specify causesvalidation, and the
validation group if you want it to perform validation. this allows
different buttons to cause different validation or non.

-- bruce (sqlwork.com)
Joey wrote:
asp.net 2/C#/VS2005

Using master pages

I have a page with several text boxes on it. I want to logically group
some of them. So I have a textbox that has required field and regular
expression validators for it. I also have a validation summary on the
page. For each of these four controls, I used the same value for the
"ValidationGroup" property. I have also assigned header text for the
validation summary and error messages for the validators.

But when I run the page, don't enter anything into the text box, and
click an image button (to trigger a postback), nothing happens. No
error message shows.

Is there something else I need to do to make this work?
May 23 '07 #2

P: n/a
Howdy,

I don't know why but it's by design (snippet from RegularExressionValidator):

protected override bool EvaluateIsValid()
{
string input = base.GetControlValidationValue(base.ControlToValid ate);
if ((input == null) || (input.Trim().Length == 0))
{
return true;
}
try
{
Match match = Regex.Match(input, this.ValidationExpression);
return ((match.Success && (match.Index == 0)) && (match.Length ==
input.Length));
}
catch
{
return true;
}
}

IMHO it looks like a big simplification (or 'screw up' would be more
convenient) from MST...

--
Milosz
"Joey" wrote:
asp.net 2/C#/VS2005

Using master pages

I have a page with several text boxes on it. I want to logically group
some of them. So I have a textbox that has required field and regular
expression validators for it. I also have a validation summary on the
page. For each of these four controls, I used the same value for the
"ValidationGroup" property. I have also assigned header text for the
validation summary and error messages for the validators.

But when I run the page, don't enter anything into the text box, and
click an image button (to trigger a postback), nothing happens. No
error message shows.

Is there something else I need to do to make this work?

May 23 '07 #3

P: n/a
Howdy,

I actually missed one thing in the documentation:
"Note Validation succeeds if the input control is empty. If a value is
required for the associated input control, use a RequiredFieldValidator
control in addition to the RegularExpressionValidator control. ". So you
have to add RequiredFieldValidator for the same control.

Regards
--
Milosz
"Milosz Skalecki [MCAD]" wrote:
Howdy,

I don't know why but it's by design (snippet from RegularExressionValidator):

protected override bool EvaluateIsValid()
{
string input = base.GetControlValidationValue(base.ControlToValid ate);
if ((input == null) || (input.Trim().Length == 0))
{
return true;
}
try
{
Match match = Regex.Match(input, this.ValidationExpression);
return ((match.Success && (match.Index == 0)) && (match.Length ==
input.Length));
}
catch
{
return true;
}
}

IMHO it looks like a big simplification (or 'screw up' would be more
convenient) from MST...

--
Milosz
"Joey" wrote:
asp.net 2/C#/VS2005

Using master pages

I have a page with several text boxes on it. I want to logically group
some of them. So I have a textbox that has required field and regular
expression validators for it. I also have a validation summary on the
page. For each of these four controls, I used the same value for the
"ValidationGroup" property. I have also assigned header text for the
validation summary and error messages for the validators.

But when I run the page, don't enter anything into the text box, and
click an image button (to trigger a postback), nothing happens. No
error message shows.

Is there something else I need to do to make this work?
May 23 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.