Click here to Skip to main content
16,012,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have dropdown list and also sub drop down list if i select fruit select in main dropdown list sub option will display that is multi select validate any one selected in save option.
tell me any idea thanks regards

What I have tried:

<asp:DropDownList ID="DropDownList4" class="form-control" runat="server">
<asp:ListItem Value="1">--SELECT--
<asp:ListItem Value="2">fruit
<asp:ListItem Value="3">veg




<asp:ListBox ID="Select49" SelectionMode="Multiple" runat="server">
<asp:ListItem Value="1"> 4
<asp:ListItem Value="2">8
<asp:ListItem Value="3">12
<asp:ListItem Value="4">16
Posted
Updated 5-May-16 3:49am
Comments
ZurdoDev 5-May-16 9:23am    
I don't understand you but I think what you want is called "cascading dropdowns."
Nethaji chennai 5-May-16 9:29am    
if i select main dropdown list item sub option will display that will validate on save function

1 solution

For validation

ASP.NET
<asp:button id="btnSave" text="Save" onclientclick="return ValidateFun();" runat="server" onclick="btnSave_Click" xmlns:asp="#unknown" />


Javascript:

<script>
    var ValidateFun = function ()
    {
        var listbox = document.getElementById('<%= Select49.ClientID%>');
        var count = listbox.selectedOptions.length;
        if (count == 0)
        { alert('Please select !!'); return false; }
        return true;
    }
</script>
 
Share this answer
 
Comments
Nethaji chennai 5-May-16 9:56am    
thankyou KARTHIK
Karthik_Mahalingam 5-May-16 10:00am    
welcome

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