Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i am new in development field..and i want to use validaton on dropdownlist..so i am not getting any idea..when to use customvalidator or some defined validators on this control or any control..if i specify just validator on control except custom...pls i wanna make it clear..the basic differences..so pls..help me out...i have used 6 validaotrs already on different controls..but i am nt quite satisfied...so pls any one help me out...thanks in advance...
Posted

1 solution

Hi,

I use javascript for validating controls.

You can my code for validating your control with some changes.

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language ="javascript" >
        function f1() {

            if (parseInt(document.getElementById("DropDownList1").selectedIndex) > 0) {
                alert("you selected option");
            }
            else {
                alert("you are Not selected ");
            }
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="divid" runat="server"></div>
     <input type ="file" id="fileupload1" />
     <input type ="button" value="change" onclick ="f1()" />
        <asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" xmlns:asp="#unknown" />
           <select name="DropDownList1" id="DropDownList1">
	<option value="dfgdfgfdg">dfgdfgfg</option>
	<option value="tytytrytry">uytuytuy</option>
	<option value="ghj">hjghj</option>
	<option value="ghjhhj">yuiyui</option>
 
</select>

    </div>
    </form>
</body>
</html>


You can change above to achieve your requirement.

All the Best
 
Share this answer
 
Comments
keshav kumar jha 22-Sep-11 5:12am    
thnx a lot..

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900