【发布时间】:2013-08-30 06:32:28
【问题描述】:
我有一个包含 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()
【问题讨论】:
-
PlaceHolder 的 ID 可能不是 HTML 元素的 ID,因为 .Net 会根据层次结构生成元素 ID。我什至没有看它的其余部分,但我会先检查那里。
标签: jquery asp.net user-controls placeholder