Click here to Skip to main content
Rate this: bad
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 11:09am
Ramanjaneya002 at 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 at 22-Nov-12 2:10am
What have you tried?
Copy your code here by clicking improve question.

1 solution

Rate this: bad
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 == "")

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

  Print Answers RSS
0 DamithSL 315
1 Zoltán Zörgő 170
2 OriginalGriff 150
3 Sergey Alexandrovich Kryukov 120
4 Maciej Los 115
0 OriginalGriff 7,760
1 DamithSL 5,874
2 Sergey Alexandrovich Kryukov 5,444
3 Maciej Los 5,076
4 Kornfeld Eliyahu Peter 4,539

Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2014
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