Gives solution for any Error occurs in any Programming Language, .Net Core 3.1, 3.0, C#,Asp.Net,Sqlserver,MVC,Java,Php,Html,Css,Jquery,errors and solutions,Latest News,Technology

Monday, 11 January 2016

Get Dropdownlist Text and Value From Client Side Using Jquery in ASP.NET,C#

No comments :
Here explaination about using jquery to get asp.net DropDownList value or text using jquery Change() event.If you select a option from dropdownlist you get alert box with text or value.
Using jquery change() event in asp.net get an value easily without postback.
ASP.Net Code : 

<asp:DropDownList ID="ddlType" runat="server">
    <asp:ListItem Text="Select" Value="0"></asp:ListItem>
    <asp:ListItem Text="Individual" Value="I"></asp:ListItem>
    <asp:ListItem Text="Family" Value="F"></asp:ListItem>
</asp:DropDownList>

jQuery Code : 

$(document).ready(function () {
           
            $("[id*=ddlType]").change(function () {               
                var value = $("[id*=ddlType] option:selected").val();
or 
                var text = $("[id*=ddlType] option:selected").text();
                alert(value);
               
            });
        });

No comments :

Post a Comment