开发者

Updatepanel equalivant in JQuery?

I am working on creating a facebook application using ASP.NET web forms. I am using Jquery for few javascript needs(like facebook calls, autocomplete, tab con开发者_JAVA百科trol, sliders etc) and also have the update panel in the page for some server side codes.

I am facing lot of conflicts with Jquery and updatepanel and partial postback is not working in most of the cases or lot of button click events are not firing , when I check the developer tools I see lot of Sys.WebForms.PageRequestManager errors.

I am thinking of removing all the updatepanels from my application, but is there anything equalivant to updatepannel in Jquery which I can use?

Thanks for your help.


You must use the Jquery Ajax. That way you can access static methods of your code behind, some service or HTTP handler.

With this your system will perform better.

Search the web, there are several articles jQuery + Ajax + ASP.NET.

thks

Vicente


That shouldn't be necessary; jQuery and UpdatePanels can play along together well as long as the events are wired up correctly. If the problem is that the UpdatePanel is causing your jQuery bindings to stop working that is because when it does a postback these are not the same elements that your javascript was originally tied to. Rebinding after the postback will fix your problem; all this requires is tying some javascript calls to a Microsoft provided call back function:

function BindEvents()
{
    //Here your jQuery function calls go
}

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(BindEvents());

The PageRequestManager will call the BindEvents function after each post back. This can go any where on the page as long as it is there prior to the postback. Typically what I will do is put all of my jQuery binding calls into one function, in this case BindEvents(), and then call that during document.ready() and just add it to the PageRequestManager.

Unfortunately I have not seen any jQuery alternative to UpdatePanels other than extensive use of Web Services and AJAX calls. This method works very well for me however.


@PCasagrande might have a fix to jQuery and UpdatePanels not working together.

To answer the question of "What is the jQuery equivalent to Updatepanel", I'd say it is the .load() method.

Put simply, you call .load() on your target/container element with a URL and a selector. When the URL's html is received, the selector is evaluated on that HTML and just the result of the selector is loaded into the target/container.

In the end, that seems to me how the UpdatePanel works. You define a container element (UpdatePanel), then reload the page and just take the part of the result that you need.

Unfortunately, you won't get all of the ViewState magic that an UpdatePanel provides, but maybe you're not using that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜