Click here to Skip to main content
12,502,578 members (54,956 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
hi guys,

pls again me out of this situation.

i have an dropdown list which is mandatory by validation and If dropdown list selected yes then text is visible. i want it will mandatory on selected yes if user select no then it is not mandatory.

pls help how can i do this.
Posted 21-Nov-12 10:09am
Comments
Ramanjaneya002 21-Nov-12 23:48pm
   
Could you please provide your dynamic generation of dropdown list.

In subject you mentioned validation for text box but in description asking validation for dropdown list.
Mohd. Mukhtar 22-Nov-12 2:10am
   
What have you tried?
Copy your code here by clicking improve question.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

on the textchange event of dropdownlist control, check whether the dropdownlist selected value is yes, if so display the textbox else dont display it.
Then validate the textbox as,
if (txt1.Visible == true && txt1.Text == "") -- you can validate like this..

or you can validate like,
if(dropdownlist.selectvalue == "Yes" && txt1.Text == "")
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160919.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100