Integrate jQuery into an existing ASP.NET web application?

Microsoft recently announced that the javascript / HTML DOM jQuery library will be integrated into ASP.NET MVC and ASP.NET/Visual Studio.

What is the best practice or strategy using jQuery with ASP.NET 2.0 ? I would like to prepare a large existing ASP.NET web application ( not MVC) for jQuery. How will I deal with versions and related issues?

Are there any caveats integrating jQuery and ASP.NET Ajax ? Or third-party components such as Telerik or Intersoft controls?

+3
source share
2 answers

There are problems for me when using UpdatePanels and jQuery (without problems with MVC, which does not have a page life cycle and is truly stateless). For example, the useful jQuery idiom


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

used to enhance the DOM or to attach to the DOM elements may not interact very well with the ASP.NET PostBack model if there are UpdatePanels on the page. So far I will get around it with the following code snippet


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

I think you need to be very careful and know the ASP.NET Page / Controls life cycle very well in order to mix both technologies.

+3
source

Source: https://habr.com/ru/post/1697662/


All Articles