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

Required Field Validator Use

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.