在服务器端禁用aspxgridviews,如何在客户端处理?

时间:2016-04-21 21:07:26

标签: javascript asp.net

我刚刚开始了一个项目,我们的BA人员需要我在一段时间后禁用所有的aspxgridviews。

C#
     public void CutoffDateTime()
      {
          //DateTime today = DateTime.Now; // this will be for live code
          DateTime today = new DateTime(2016, 4, 15, 7, 00, 00); // for testing
          DateTime cutoff = new DateTime(2016, 4, 19, 7, 00, 00);

          if (today >= cutoff.AddDays(7))
          {
              cutoff = cutoff.AddDays(7);
          }
          // if today is past cutoff, disable all grids
          if (today < cutoff.AddHours(-55))
          {
              gvProduction.Enabled = false;
              gvProductionSummary.Enabled = false;
              gvDowntimeSummary.Enabled = false;
              gvNonProd.Enabled = false;
              cbCutoff.Checked = false;
          }
          else
              cbCutoff.Checked = true;
    }

网格被正确禁用,但这会影响一些调用grid.Refresh()方法的客户端代码。

我已将复选框添加为不可见的控件,以便我可以轻松地与客户端进行交互,并且我正在尝试添加:

JS
    if (cbCutoff.GetChecked()==true)
        grid.Refresh();

但我仍然收到JavaScript运行时错误,指出'cbCutoff未定义'但我想不出另一种方法来完成这项任务。

由于

修改

这是我的asp.net标记的一部分,我试图通过DexExpress的GetChecked()方法修复,如果选中则返回true:

ASPX

<ClientSideEvents ActiveTabChanged="function(s, e) {
    if (e.tab.index.toString() ==  1 && cbCutoff.GetChecked()==true)
        gridProductionSummary.Refresh();
}" />

1 个答案:

答案 0 :(得分:0)

使用

修复
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>

<div class="inner">
    <button data-target="#data-nav-0" data-toggle="collapse" data-state="show" class="list-header major no-style"><span>HEADER</span>
    </button>
    <div class="col-wrapper collapse in" id="data-nav-0" style="display: block;">
        <div class="column">
            <ul class="list-unstyled">

                <li class="list-header mobile"><a href="#" class="link">link</a></li>
                <li class="list-header desktop"><a href="#">head</a></li>
                <li class="mobile chevron-right" data-target="#data-inner-0-0" data-toggle="collapse" data-state="hide">
                    <button class="no-style sub-header">This should toggle the ul links</button>
                </li>

                <ul class="inner collapse" id="data-inner-0-0">
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                </ul>
            </ul>
        </div>
        <div class="column">
            <ul class="list-unstyled">
                <li class="list-header desktop"><a href="#">Link</a></li>
                <li class="mobile chevron-right" data-target="#data-inner-0-1" data-toggle="collapse" data-state="hide">
                    <button class="no-style sub-header">This should toggle the ul links</button>
                </li>

                <ul class="inner collapse" id="data-inner-0-0">
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                </ul>
            </ul>
            </ul>
        </div>
    </div>
</div>

<div class="inner">
    <button data-target="#data-nav-0" data-toggle="collapse" data-state="show" class="list-header major no-style"><span>HEADER</span>
    </button>
    <div class="col-wrapper collapse in" id="data-nav-0" style="display: block;">
        <div class="column">
            <ul class="list-unstyled">

                <li class="list-header mobile"><a href="#" class="link">link</a></li>
                <li class="list-header desktop"><a href="#">head</a></li>
                <li class="mobile chevron-right" data-target="#data-inner-0-0" data-toggle="collapse" data-state="hide">
                    <button class="no-style sub-header">This should toggle the ul links</button>
                </li>

                <ul class="inner collapse" id="data-inner-0-1">
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                </ul>
            </ul>
        </div>
        <div class="column">
            <ul class="list-unstyled">
                <li class="list-header desktop"><a href="#">Link</a></li>
                <li class="mobile chevron-right" data-target="#data-inner-0-1" data-toggle="collapse" data-state="hide">
                    <button class="no-style sub-header">This should toggle the ul links</button>
                </li>

                <ul class="inner collapse" id="data-inner-0-2">
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                    <li><a href="#" class="link">link</a></li>
                </ul>
            </ul>
            </ul>
        </div>
    </div>
</div>

并将复选框设置为在服务器端启用