我如何调用从后面ASP.NET code一个jQuery UI对话框没有客户端的事件? [英] How do I call up a jQuery UI dialog from ASP.NET code behind without a client-side event?

查看:102
本文介绍了我如何调用从后面ASP.NET code一个jQuery UI对话框没有客户端的事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据基于按一下按钮或其他客户端事件的值是一个特定的范围之外,而不是从我的C#ASP.NET code打开一个jQuery UI的对话框。这里是一个创建对话框(在.aspx页的顶部)的JavaScript函数:

I'm trying to open a jQuery UI dialog from my C# ASP.NET code based on a value being outside a certain range, rather than based on a button click or other client-side event. Here's the Javascript function that should create the dialog (at the top of the .aspx page):

<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页的底部):

Here's the dialog div itself (at the bottom of the .aspx page):

<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#code的后面部分试图显示对话框:

And here's the section of the C# code behind that attempts to display the dialog:

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);
}

在code在如果正在达到块,如果我通过它在调试步骤执行,但没有显示该对话框。我缺少什么?

The code in the if block is being reached and executed if I step through it in the debugger, but the dialog isn't being displayed. What am I missing?

推荐答案

我稍微修改我的功能,基于一个问题/答案我发现在<一个href=\"http://stackoverflow.com/questions/12704225/how-do-i-open-a-jquery-ui-dialog-from-my-c-sharp-$c$c-behind?rq=1\">How我从后面我的C#code。打开一个jQuery用户界面对话框?,现在它的作品。下面是修改后的功能:

I modified my function slightly, based on a question/answer I found at How do I open a jQuery UI Dialog from my c# code behind?, and now it works. Here's the modified function:

<script type="text/javascript">
  //Total out of range dialog
  function ShowRangeDialog() {
    $(function() {
      $('#rangeDialog').dialog({
        modal: true,
        width: 'auto',
        resizable: false,
        draggable: false,
        close: function (event, ui) { $('body').find('#rangeDialog').remove(); },
        buttons: { 'OK': function () { $(this).dialog('close'); }
        }
      })
    }).dialog("open");
  }
</script>

这篇关于我如何调用从后面ASP.NET code一个jQuery UI对话框没有客户端的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆