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
- ModuleNotFounEerror:No module named celery in Django Project
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
Related Article