<asp:UpdatePanel ID="showsDatalistPanel" runat="server" Visible="false" UpdateMode="Always">
<ContentTemplate>
<div>
<asp:DropDownList ID="dateTimeFilter" CssClass="dateTimeFilterIdentifierCls" runat="server"
onclick="dateTimeFilter_SelectedIndexChanged" AutoPostBack="true" Visible="true" ClientIDMode="Static">
</asp:DropDownList>
<label id="dateTimeFilterLabel" runat="server" style="padding-left: 15px" visible="false">
בחירת מופע לפי תאריך
</label>
</div>
如何在单击下拉菜单时调用服务器端功能? 谢谢
答案 0 :(得分:0)
如果您确实要使用click事件,则必须使用JS模拟它,因为DropDownList没有内置的onclick功能:
<asp:DropDownList ID="dateTimeFilter" CssClass="dateTimeFilterIdentifierCls" runat="server"
onclick="__doPostBack('dateTimeFilter', null);" AutoPostBack="true" Visible="true" ClientIDMode="Static">
</asp:DropDownList>
,然后在服务器代码中相应地修改页面加载事件:
protected void Page_Load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
if(Request.Params.Get("__EVENTTARGET").ToString() == dateTimeFilter.ClientID)
{
dateTimeFilter_SelectedIndexChanged(dateTimeFilter, null);
}
}
}
但是我很困惑为什么您不能只使用标准的OnSelectedIndexChanged或OnSelectedValueChanged?