【发布时间】:2015-08-19 14:21:29
【问题描述】:
我的 jquery 对话框中有一个列表框,
<div id="dialog">
<asp:UpdatePanel ID="updatePanel1" runat="server">
<ContentTemplate>
<asp:ListBox ID="lbxTitle" runat="server" style="width:400px;height:100px;" OnSelectedIndexChanged="lbxTitle_SelectedIndexChanged">
<asp:ListItem value="2" Text="abc" />
<asp:ListItem value="3" Text="def" />
</asp:ListBox>
<br />
<fieldset>
<asp:Label ID="lblContent" runat="server" style="height:200px;" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</div>
在后面的代码中,我有这个功能
protected void lbxTitle_SelectedIndexChanged(object sender, EventArgs e)
{
lblContent.Text = "test";
}
我没有放 autopostback="true" 因为它会刷新整个页面,并关闭我的对话框。
如何使当用户单击列表框上的项目时,它会在对话框内的标签上显示“测试”。
现在,如果我更改所选项目,它不会做任何事情。
【问题讨论】:
-
它不会刷新整个页面,而只会刷新
UpdatePanel的内容。异步回发始终是完整回发。 -
看看我的回答是否为你解决了这个问题。
-
我尝试输入
autopostback,但它确实刷新了整个页面,即使我在updatePanel中有listbox。 @TimSchmelter -
@Bee:“刷新整个页面”是什么意思?
-
listbox位于一个弹出对话框中显示对话框。是否可以不刷新页面而只更改对话框内的值? @TimSchmelter
标签: c# asp.net listbox updatepanel autopostback