获取在占位符中动态创建的用户控件中的Dropdownlist的Jquery值

时间:2013-08-27 13:20:34

标签: jquery asp.net user-controls placeholder

我有一个包含DropdownList的用户控件。 我使用占位符在Web表单中使用此用户控件。我动态创建这个用户控件 我需要知道,当下拉列表更改(回发)时,如何从JQuery的下拉列表中获取占位符中的选定值? 这是我的用户控件:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="IVT_DropDownList.ascx.cs" Inherits="Evi.Sc.Web.Evi.IVT.Sublayouts.IVT_DropDownList" %>
<asp:DropDownList ID="DropDownList" runat="server" AutoPostBack="True">
</asp:DropDownList>

这是占位符:

<asp:PlaceHolder ID="plhStatusClient" runat="server"></asp:PlaceHolder>

这是代码隐藏:

IVT_DropDownList UC_StatusClients = (IVT_DropDownList)LoadControl("~/Evi/IVT/Sublayouts/IVT_DropDownList.ascx");

            IvtStatusClient ivtStatusClient = new IvtStatusClient();

            //Get the database to retrieve the information of the status
            var lstStatusClients = ivtStatusClient.Get_AllStatusClients();

            UC_StatusClients.DataSource = lstStatusClients;
            UC_StatusClients.InsertFirstRow = new ListItem("All", "0");
            plhStatusClient.Controls.Add(UC_StatusClients);

我正在尝试这个,但不起作用。

$("#plhStatusClient").val()

2 个答案:

答案 0 :(得分:1)

ASP.NET以不同的方式呈现ID,尝试使用.ClientID

$("#<%= plhStatusClient.ClientID %>").val()

答案 1 :(得分:0)

<asp:PlaceHolder ID="plhStatusClient" runat="server" clientID="test">
</asp:PlaceHolder> // use client id  here i give an idea to use client id
在jquery中

$("#test").val();
相关问题