【问题标题】:asp:UpdatePanel + postback + JQuery class selectorasp:UpdatePanel + postback + JQuery 类选择器
【发布时间】:2012-11-14 16:41:54
【问题描述】:

我有一个简单的页面,带有 asp:UpdatePanel 和执行回发的按钮。页面在 Page_Load 服务器方法中有简单的脚本:

ScriptManager.RegisterStartupScript(Page, Page.GetType(), "initPage", "initPage();", true); 

Javascript 函数 initPage() 如下所示:

function initPage(){
  $('.textBoxClass').each(function (index) {
    alert(index);
  }
}

问题是,点击回发按钮后,$('.textBoxClass') 的长度会增加一。没有代码生成、DOM 操作或类添加。我认为它与 UpdatePanel(?)有关,但有什么办法可以摆脱类数的增加?

【问题讨论】:

  • 也许键盘和椅子之间有错误 - 我重试了这个简单的例子,现在一切正常。 ://

标签: c# jquery asp.net postback


【解决方案1】:

尝试设置:

UpdateMode="Conditional" 

在 updatepanel 属性中,仅在必要时使用 Update() 方法更新面板。

您也可以尝试评论更新面板以使用警报消息进行一些测试

如果这种行为仍然存在,请告诉我们。

【讨论】:

    猜你喜欢
    • 2013-03-01
    • 2015-02-26
    • 1970-01-01
    • 2011-04-15
    • 2016-05-05
    • 2014-01-19
    • 2011-07-26
    • 2012-01-30
    • 2012-05-15
    相关资源
    最近更新 更多