473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Validation Groups

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
3 3471
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ing. Rajesh Kumar | last post by:
Hi everybody Validation controls are great but i have a scenario where i do not know how to use them so i am doing my validation on the server. Let's say I have a Web Form with : Two Textboxes :...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two...
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
1
by: Kris | last post by:
Hi, I have a DataGrid where in each row has couple of text boxes and an update button. Each row is dynamically generated as the number of rows are not known ahead of time. When the user clicks the...
1
by: MattC | last post by:
I have a user control that contains several requiredFieldValidators. The page the control sits in has other RequiredFieldValidators. On submitting the form all the validators on the page fire and...
4
by: ibiza | last post by:
Hi all, I have a small question concerning asp.net 2.0 validation groups. I have this (simplified) situation : Name Value _____ _____ |_____| |_____| _____ _____...
1
by: misiek | last post by:
Hi all. I have following problem: I have some user control called smallUserContrl, in which I have two RangeValidator controls. I set their ValidationGroup property to smallUserControlGroup. ...
1
by: brantman | last post by:
Here is a question that needs to be revisited. I noticed that there are more that a few posts about this in this group and in custom controls. Here is the problem: When inheriting from a...
2
by: moondaddy | last post by:
How can I have a page with 2 different groups of controls (where each group of controls contain textboxes, validation controls and a submit button) and each group operate independently? for...
1
by: Velvet | last post by:
Does anyone know a way to force the client script to preform a client-side validation for controls in validation groups? What is currently happening is I have two validation groups (Billing,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.