【问题标题】:clientidmode static is not working with updatepanel which forces full postbackclientidmode static 不适用于强制完整回发的更新面板
【发布时间】:2016-04-12 09:28:05
【问题描述】:

我的页面中有 RadioButtonList 和 Listvie。我正在使用更新面板来避免回发现在我的 radioButtonList 用作列表视图的过滤器。我的问题在我的 radiobuttonList 中,我必须使用 clientIDmode=static 但如果我这样做了,那么我的更新面板就没有用了,因为当 radiobuttonList 被更改时会有完整的回发。如何在不删除 clientIdmode=static 的情况下解决此问题。我看到了一些相同帖子的解决方案,但真的不明白。请帮帮我。

我的代码具有以下结构。

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:RadioButtonList ID="areasList" CssClass="mark" AutoPostBack="true" runat="server" ClientIDMode="static" RepeatLayout="Flow">
</asp:RadioButtonList>
ListviewHere
</ContentTemplate>
</asp:UpdatePanel> 

【问题讨论】:

  • 只是好奇:为什么你“必须使​​用”ClientIDMode="Static"
  • @ConnorsFan 因为我在切换中有 radioButtonList,如果我不使用 clientIDMde=static 则切换功能不起作用,因为页面加载时 ID 会被修改

标签: asp.net vb.net updatepanel


【解决方案1】:

你的脚本有问题。

回发后没有调用您的脚本。

所以如下使用,

<script type="text/javascript">
    // below will execute after ajax postback
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

    function EndRequestHandler(sender, args) {
        //script
    }

    // executes after page load first time

    //script

</script>

【讨论】:

    【解决方案2】:

    您可以将 RadioButtonList 的 ClientIDMode 设置为 AutoID(如果这是默认值,则不指定标记中的属性)并在客户端代码中使用绑定表达式来获取控件的实际 ID:

    $("#<%= areasList.ClientID %>")
    

    document.getElementById('<%= areasList.ClientID %>')
    

    【讨论】:

      猜你喜欢
      • 2012-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-12
      • 2013-06-30
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多