473,386 Members | 1,832 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,386 software developers and data experts.

programmatically set which validation groupS to use

Hi all,

I have a small question concerning asp.net 2.0 validation groups. I
have this (simplified) situation :

Name Value
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|

So I have 6 textboxes, that goes in pair by row. I'd like the user to
choose whatever boxes he wants to fill, meaning that he can save either
one, two or three name-value pairs. The problem is, a name cannot be
saved without a value and vice-versa. I thought asp.net 2.0 would solve
my validation problems with its new "groups" feature, but I can't
manage how to tell him that "if the user fills one box, the other
besides it must also be filled". I tried many different ways of doing
this, right now I ended with 6 requiredfieldvalidator and textboxes
aside set with the same ValidationGroup, for a total of 3 different
ValidationGroup-s. Can't I programmatically set which ValidationGroup I
want to use just before Page.Validate or anything like this that would
do the job?.....

thanks for your feedback,

ibiza

Feb 6 '06 #1
4 2685
Try setting the ValidationGroup properties for your respective controls in
the Page_Load method.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

I have a small question concerning asp.net 2.0 validation groups. I
have this (simplified) situation :

Name Value
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|

So I have 6 textboxes, that goes in pair by row. I'd like the user to
choose whatever boxes he wants to fill, meaning that he can save either
one, two or three name-value pairs. The problem is, a name cannot be
saved without a value and vice-versa. I thought asp.net 2.0 would solve
my validation problems with its new "groups" feature, but I can't
manage how to tell him that "if the user fills one box, the other
besides it must also be filled". I tried many different ways of doing
this, right now I ended with 6 requiredfieldvalidator and textboxes
aside set with the same ValidationGroup, for a total of 3 different
ValidationGroup-s. Can't I programmatically set which ValidationGroup I
want to use just before Page.Validate or anything like this that would
do the job?.....

thanks for your feedback,

ibiza

Feb 7 '06 #2
How wil this solve my problem? (and would the client validation fail
with your method?)

Feb 7 '06 #3
You set the ValidationGroup properties as you need to in the Page_Load
before the Page_Render so that when you go through validation on your
postback, you have the ValidationGroup properties defined as you want.

If you want to change the ValidationGroup properties on the postback, I
don't believe you can do that because the ValidationGroup property is used
in the rendering step to set up which button will be validated with which
field validator.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
How wil this solve my problem? (and would the client validation fail
with your method?)

Feb 8 '06 #4
Validation Groups is not designed for this. It lets a submit control
determine which validators to fire.

You need a way to disable/enable a validator based on the value of something
else on the page. There is no built in feature to do that in ASP.NET on the
validators. You have several options:
1. Post back to the server side to handle validation. (No client-side
validation.) I describe a technique in this article about common issues with
validators: http://aspalliance.com/699.
2. Write javascript code that is called when the value of the textbox
changes, to enable the validator on the client-side. The validation scripts
include this function:
function ValidatorEnable(val, enable)
val - use document.getElementById('ClientID of the validator')
enable - true or false

3. Use my replacement to the ASP.NET Validators, Professional Validation And
More (http://www.peterblum.com/vam/home.aspx). Its 25 validators have this
capability built in. Use the Enabler property to describe the rule that
enables the validator. For more:
http://www.peterblum.com/VAM/DemoEnabler.aspx

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"ibiza" <la******@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

I have a small question concerning asp.net 2.0 validation groups. I
have this (simplified) situation :

Name Value
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|
_____ _____
|_____| |_____|

So I have 6 textboxes, that goes in pair by row. I'd like the user to
choose whatever boxes he wants to fill, meaning that he can save either
one, two or three name-value pairs. The problem is, a name cannot be
saved without a value and vice-versa. I thought asp.net 2.0 would solve
my validation problems with its new "groups" feature, but I can't
manage how to tell him that "if the user fills one box, the other
besides it must also be filled". I tried many different ways of doing
this, right now I ended with 6 requiredfieldvalidator and textboxes
aside set with the same ValidationGroup, for a total of 3 different
ValidationGroup-s. Can't I programmatically set which ValidationGroup I
want to use just before Page.Validate or anything like this that would
do the job?.....

thanks for your feedback,

ibiza

Feb 9 '06 #5

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

Similar topics

6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
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...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...

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.