【发布时间】:2011-10-04 07:59:13
【问题描述】:
我遇到了从更新面板内的按钮调用 Jquery 模态对话框的问题..
以下是见解..
用于在 aspx 页面中打开 Jquery 模式对话框的 Javascript..
<script type='text/javascript'>
function openModalDiv(divname) {
$('#' + divname).dialog({
autoOpen: false,
bgiframe: true,
closeOnEscape: true,
modal: true,
resizable: false,
height: 'auto',
buttons: { Ok: function () { closeModalDiv(divname) } },
open: function (event, ui) { jQuery('.ui-dialog-titlebar-close').hide(); }
});
$('#' + divname).dialog('open');
('#' + divname).parent().appendTo($('form:FrmSearch'));
$('#' + divname).css('overflow', 'hidden')
}
function closeModalDiv(divname) {
$('#' + divname).dialog('close');
}
</script>
aspx 页面中的按钮..
<asp:UpdatePanel ID="upDialogs" runat="server">
<ContentTemplate>
<asp:Button ID="btnOpenDialog" runat="server" Text="Open Dialog" onclick="btnOpenDialog_Click" />
</ContentTemplate>
</asp:UpdatePanel>
需要通过javascript从后面的代码中调用的Div..
<div id="ErrorDiv2" title="Error" style="visibility:hidden">
<p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>Please select an option among the results and try again!</p>
</div>
最后是后面的代码..
protected void btnOpenDialog_Click(object sender, EventArgs e)
{
if (ProfileID == null)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivOpen", "document.getElementById('ErrorDiv2').style.visibility = 'visible';", true);
Page.ClientScript.RegisterStartupScript(this.GetType(), "ErrorDivShow", "openModalDiv('ErrorDiv2');", true);
}
}
现在详细说明问题.. 如果没有更新面板,模态对话框会非常好地弹出,但会完整回发..
我只想回复部分帖子,因此我正在使用更新面板..
以下是我尝试过的解决方案..
- 在现有 div 中添加了更新面板,效果不错。
- 为 div 添加了一个更新面板以及 runat="Server",仍然可以正常工作..
谁能帮我解决可能的问题?
【问题讨论】:
标签: c# jquery asp.net postback jquery-ui-dialog