我在Page_Load
期间发生错误时尝试打开信息错误对话框
我已经定义了初始化打开它的对话框和函数,如下所示:
$(document).ready(function () {
$('#errorDialog').dialog({
autoOpen: false,
height: 120,
width: 500,
draggable: false,
resizable: false,
modal: true,
title: "Error!",
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
});
function showErrorPopup() {
$('#addNoteButton').hide();
$('#errorDialog').dialog("open");
}
<div id="errorDialog">
<asp:Label ID="errMessage" runat="server"></asp:Label>
<input type="button" id="Button3" onclick="closeDialog('errorDialog');"
class="inputASPButton" value="Zrušit" />
</div>
我从Page_Load
这样打开它:
Page.ClientScript.RegisterStartupScript(typeof(Page), UniqueID, "showErrorPopup();", true);
调用该函数,当$('#addNoteButton').hide();
执行时,隐藏按钮,但对话框本身从不显示。
非常感谢任何帮助。
答案 0 :(得分:2)
由于我无法看到您包含的脚本库,我唯一可以建议的是确保您包含jQuery UI(http://jqueryui.com/download/),因为Dialog Widget是此库的一部分而不是标准的jQuery库。我纯粹基于这样一个事实,即您可以按预期隐藏按钮,但无法打开对话框。
答案 1 :(得分:1)
如果您的错误消息不是动态的,您可以使用此代码
Page.RegisterStartupScript(“err_msg”,“alert('找不到开始日期!');”);
答案 2 :(得分:0)
在从=Repetitions(A2:F2)
显示jquery-ui对话框之前,我必须像$(function(){ showErrorPopup(); });
这样包装我的函数调用。