我试图从我的 C# ASP.NET 代码中打开一个 jQuery UI 对话框,该对话框基于某个范围之外的值,而不是基于按钮单击或其他客户端事件。这是应该创建对话框的 Javascript 函数(在 .aspx 页面的顶部):
<script type="text/javascript">
//Total out of range dialog
function ShowRangeDialog() {
$('#rangeDialog').dialog({
modal: true,
width: 'auto',
resizable: false,
draggable: false,
close: function (event, ui) {
$('body').find('#rangeDialog').remove();
},
buttons:
{
'OK': function () {
$(this).dialog('close');
}
}
});
}
</script>
这是对话框 div 本身(在 .aspx 页面的底部):
<div id="rangeDialog" style="display: none;" title="Total out of range">
<p>
Your line items total is out of the range allowed by the approval level you chose.
Please check the approval range and adjust the line items or quantities.
</p>
</div>
下面是尝试显示对话框的 C# 代码部分:
if (currTotal < lowerLim || currTotal > upperLim)
{
//Show jQuery dialog telling user that their line items total is out of range
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "dlgOutOfRange",
"ShowRangeDialog();", true);
}
如果我在调试器中单步执行该if
块中的代码,则会到达并执行该代码,但未显示对话框。我错过了什么?