将jQuery集成到现有的ASP.NET Web应用程序中?

3

Microsoft 最近宣布,Javascript/HTML DOM库jQuery将被整合到ASP.NET MVC框架和ASP.NET/Visual Studio中。

在使用ASP.NET 2.0时,采用jQuery的最佳实践或策略是什么?我想为一个大型现有的ASP.NET Web应用程序(不是MVC)准备jQuery。我应该如何处理版本和相关问题?

整合jQuery和ASP.NET Ajax第三方组件如Telerik或Intersoft控件时,是否存在任何注意事项?

2个回答

3

对我来说,当使用UpdatePanels和jQuery时会出现问题(在MVC中没有问题,因为它没有页面生命周期,是真正的无状态)。例如,有用的jQuery习语


$(function() {
  // some actions
});

used to enhance your DOM or attach events to the DOM elements may not interact very well with the ASP.NET PostBack model if there are UpdatePanels in the page. By now, I circumvent it with the following code snippet


if (Sys.WebForms.PageRequestManager) {
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() {
    $('#updateListView1').trigger("gridLoaded");
  });
}
where gridLoaded will be the replacement of $(document).ready.

我认为你需要更加仔细地了解ASP.NET页面/控件的生命周期,才能够混合使用这两种技术。


1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接