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

Wednesday, 13 January 2016

Select Dropdownlist Text and Value using JavaScript in ASP.Net C#

No comments :

Here I explain about get DropDownList text and value while changing from it using JavaScript.

ASP.NET Code:
<asp:DropDownList ID="ddlType" runat="server" onchange=GetTeamUsersByTeamID(this.value)>
    <asp:ListItem Text="Select" Value="0"></asp:ListItem>
    <asp:ListItem Text="Show" Value="S"></asp:ListItem>
    <asp:ListItem Text="Hide" Value="H"></asp:ListItem>
</asp:DropDownList>
JavaScript Code:
 function GetTeamUsersByTeamID(selectedvalue) {
          var value = $("[id*=ddlCallType] option:selected").val();
           if (value == "S")
               alert($("[id*=ddlCallType] option:selected").text());
            else if (value == "I")
               alert($("[id*=ddlCallType] option:selected").text());

        }

No comments :

Post a Comment