【发布时间】:2016-08-26 13:41:45
【问题描述】:
我有一个这样的 aspx 页面:
<asp:UpdatePanel runat="server" UpdateMode="always">
<ContentTemplate>
<asp:DropDownList autopostback="true" runat="server" ID="DropDown1" OnSelectedIndexChanged="DropDown1_SelectedIndexChanged">
</asp:DropDownList>
<asp:DropDownList autopostback="true" runat="server" ID="DropDown2" OnSelectedIndexChanged="DropDown2_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
在 2 个下拉列表中的任何一个中的每个 selectionChanged 处,都会完成部分回发,并且我会刷新 updatePanel 内容。但是,我只想在 DropDown1 的 selectionChanged 触发刷新面板后执行一些 js 代码。
我怎样才能在我的页面中进入客户端,在 updatePanel 刷新之后的事件,更重要的是,触发刷新面板的控件的 id(在本例中为 DropDown1)。
我试过这个,但每次加载页面时都会调用它,即使是第一次,我也不知道哪个控件触发了 updatePanel 刷新:
<script>
$(document).ready(function ()
{
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded)
});
function PageLoaded(sender, args) {
// I have analyzed sender and args without any information to obtain the desired id "DropDown1"
}
</script>
【问题讨论】:
标签: javascript c# jquery asp.net updatepanel