我正在尝试更新模式对话框的内容。我在对话框中使用了一个updatepanel,但是页面会刷新,所以对话框关闭了。
$("#dlg").dialog({
autoOpen: false,
bgiframe: true,
width: 500,
modal: true,
closable: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$("#dlg").parent().appendTo($("form:first"));
function openDialog() {
$('#dlg').dialog('open')
return false;
}页面如下:
<div id="dlg">
<asp:UpdatePanel ID="upNewUpdatePanel" runat="server">
<ContentTemplate>
<asp:Label ID="updateLabel" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:LinkButton ID="updateSomething" runat="server" Text="Update" CausesValidation="false" OnClientClick="openDialog();" onclick="UpdateButton_Click" />和update函数:
protected void UpdateButton_Click(object sender, EventArgs e)
{
updateLabel.Text = DateTime.Now.ToString();
}谁能告诉我,要想在不刷新页面的情况下更新对话框,需要做些什么?
发布于 2011-06-08 09:44:43
您必须在updatepanel中定义linkbutton的AsyncPostBackTrigger,如下所示
<asp:UpdatePanel ID="upNewUpdatePanel" runat="server">
<ContentTemplate>
<asp:Label ID="updateLabel" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="updateSomething" EventName="Click" />
</Triggers>
</asp:UpdatePanel>发布于 2011-06-08 09:51:39
巴拉是对的。我很确定这一点,但有一件事要记住,如果你在$(document).ready()中连接对话框,当UpdatePanel刷新时,它不会被保留。实际上,页面的这一部分将被重新创建(部分页面回发),并且在加载文档时连接的任何事件都将丢失。我在过去遇到过这种情况--我非常确定这就是正在发生的事情。
希望这能有所帮助。
https://stackoverflow.com/questions/6273375
复制相似问题