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

Required Field Validator Use

Is it possible to use a required field validator and have it make a user
answer a comment field based on a drop down value picked? For instance, if
the user selects "It was terrible", make them have to enter comments before
allowing that page to be submitted.

If that cannot be done, what is the best way to do this. What makes it
harder is that the questions are being placed on the form from a database
dynamically, so we cannot write any java code ahead of time.

Any replies would be greatly appreciated.
Aug 9 '06 #1
3 5064
1)Enable your DropDownList Control for AutoPostBack
2)Implement SelectedIndexChanged Event so thet you Enable or Disable your
Required Field Validator according to the value selected from the DropDownList
for example:

if(cmb.SelectedValue =="YourValue")
{
RequiredFieldValidator1.Enabled = true;
}
else
{
RequiredFieldValidator1.Enabled = false;

}
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
"Mike Collins" wrote:
Is it possible to use a required field validator and have it make a user
answer a comment field based on a drop down value picked? For instance, if
the user selects "It was terrible", make them have to enter comments before
allowing that page to be submitted.

If that cannot be done, what is the best way to do this. What makes it
harder is that the questions are being placed on the form from a database
dynamically, so we cannot write any java code ahead of time.

Any replies would be greatly appreciated.
Aug 10 '06 #2
Thanks...I will look at your solution.

I am actually hoping to do this client side. I believe I have a good
solution I am coding. I will add an attribute to the dropdown that runs a
java script that takes in the dropdown object, the object that needs
validation, and the values of the dropdown that will cause the validation to
be enabled. Then I will check to see if the dropdown value selected is one
that I will be looking for and then validate the object then. I will then
attempt to attach this to the page submit event.

Thanks for your response though...I did not think of having the dropdown
post back.

"Muhammad Mosa" wrote:
1)Enable your DropDownList Control for AutoPostBack
2)Implement SelectedIndexChanged Event so thet you Enable or Disable your
Required Field Validator according to the value selected from the DropDownList
for example:

if(cmb.SelectedValue =="YourValue")
{
RequiredFieldValidator1.Enabled = true;
}
else
{
RequiredFieldValidator1.Enabled = false;

}
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
"Mike Collins" wrote:
Is it possible to use a required field validator and have it make a user
answer a comment field based on a drop down value picked? For instance, if
the user selects "It was terrible", make them have to enter comments before
allowing that page to be submitted.

If that cannot be done, what is the best way to do this. What makes it
harder is that the questions are being placed on the form from a database
dynamically, so we cannot write any java code ahead of time.

Any replies would be greatly appreciated.
Aug 10 '06 #3
You should use CustomValidator for this purpose. A RequiredFieldValidator
will not work on conditional basis. That is how it was in .net 1.1.. I am
not sure if it has changed the way it works in asp.net 2.0

"Mike Collins" <Mi*********@discussions.microsoft.comwrote in message
news:CF**********************************@microsof t.com...
Is it possible to use a required field validator and have it make a user
answer a comment field based on a drop down value picked? For instance, if
the user selects "It was terrible", make them have to enter comments
before
allowing that page to be submitted.

If that cannot be done, what is the best way to do this. What makes it
harder is that the questions are being placed on the form from a database
dynamically, so we cannot write any java code ahead of time.

Any replies would be greatly appreciated.

Aug 10 '06 #4

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

Similar topics

2
by: Martin | last post by:
Dear Group It says in MSDN that a field can be associated with more than one validators but can one validator be associated with more than one field? Or do I need a validator for each field? How...
2
by: z. f. | last post by:
Hi, i have a field with required field validator. on the client side it's working. when i submit without the required field the page gets back because of not valid, but the message from the...
1
by: Brian Shannon | last post by:
I built a composit control consisting of a calandar control and a text box and an image of a calandar. Depending on what page I place this control the Date field needs to be required. If the...
1
by: Sam Collett | last post by:
Is there a way of having a required field validator check to see if at least one of a set of controls has information in it? I'm sure this can somehow be done using a custom validator, but would...
2
by: pmud | last post by:
Hi, I have an ASP.Net web page . The page was working fine until I added a required field field validator. My page has a link button which takes the user to another page, a submit button which...
3
by: Skeptical | last post by:
Hello, I have a form and two buttons on it. Button1 submits the data to a database and RequiredFieldValidator is used to make sure all the required fields are filled up, the second button has a...
2
by: David Hearn | last post by:
I have some required field validators on a form and would like to know if there is a way to set focus back to the field that is required if the validator is triggered. The problem is that the...
3
by: Kivak Wolf | last post by:
Hi, Could someone give me a quick review of how to use the required field Validator? I'm completely at a loss, and MSDN does not help one bit. =/ Basically all I want done is to make sure that...
0
by: nimeshdotnet | last post by:
Hi All, I have a textbox whose readonly property is set to true. This textbox is also guarded by a required field validator. What i m doing that I have a calendar control whose on date selection i...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.