In this Article, I explain how to get selected dropdown text and value using jquery in asp.net. Here I am using jquery 1.8.3 for achieve this. Here I demonstrate a simple example of binding a country with dropdownlist.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function getvalue() {
var cbocountry = $('#cbocountry');
var selecttext = cbocountry.find('option:selected').text();
alert(selecttext);
var selectedvalue = $('#cbocountry').val();
alert(selectedvalue);
}
</script>
<asp:DropDownList ID="cbocountry" runat="server">
<asp:ListItem Text="India" Selected="True" Value="1" />
<asp:ListItem Text="UAE" Value="2" />
<asp:ListItem Text="KSA" Value="3" />
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="Getselectedvalue" OnClientClick="getvalue()" />
Post your comments / questions
Recent Article
- How to add two numbers in Android Studio? | Source Code
- FindViewByID returns null in android studio -SOLVED
- Saving changes is not permitted in SQL SERVER - [SOLVED]
- Restore of database failed. File cannot be restored over the existing. -[SOLVED]
- One or more projects in the solution were not loaded correctly in Visual Studio 2019 | FIXED
- How to find Laptop's Battery Health?
- SOLVED-Related Field got invalid lookup: icontains error in Django
- How to enable Search Feature in Django admin?
Related Article