开发者

Multiple update panels and multiple postbacks cause entire page to refresh

开发者 https://www.devze.com 2022-12-26 16:30 出处:网络
I\'m having the same problem I had yesterday... The solution Aristos provided helped solve the problem, but I have other places sending updatepanel postbacks causing the same problem.

I'm having the same problem I had yesterday... The solution Aristos provided helped solve the problem, but I have other places sending updatepanel postbacks causing the same problem.

When an update panel is updated and another request for an update is called before it has a chance to render the first updates, the entire page refreshes instead of just the update panel.

I used fiddler to see what was going on and here's what happens... If I wait for the request to return before doing another request I get this:

21443|updatePanel|dnn_ctr1107_CRM_SalesTool_LeadsUpdatePanel|

But if I don't wait, I get this:

66|pageRedirect||http://mysite.com/salesdashboard.as开发者_Python百科px|

The code from the previous question is still the same except I added UpdateMode="Conditional" to the update panel.

Any ideas? Or is the only solution to this making sure that 2+ updates for any number of update panels (as long as they're on the same page) never happen?

Thanks,

Matt


Maybe microsoft automatic ajax can not handle 2 request at the same time because he needs to know what is the post back every time, so probably if you click when he wait for a return, then he knows that the post back, has change, so he by pass ajax to be soure for correct return.

I can think 2 ways. One way is to make it by your self using jQuery and ajax and avoid UpdatePanel.

Second way, is to block the clicks when you wait for the return, or make a mechanism to place the request, the one after the other.

This code can help you know when you block the input and when you release it, or do what ever you think.

$(document).ready(function() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    prm.add_initializeRequest(InitializeRequest);
    prm.add_endRequest(EndRequest);
});

function InitializeRequest(sender, args) {  
   LastIdCaller = args.get_postBackElement().id;    
}

function EndRequest(sender, args) {
}


I could be wrong, but if I'm right then you can't do multiple ajax request if you are using asp.net WebForms. In asp.net WebForms there is only one Form element on a page. Multiple ajax requests on the same page require multiple form elements for each. Html is designed to post back inside a form element and the mechanism that handles said postback is the form, it's the container. Only one can post back at a time. So because Asp.Net WebForms only has one form element per page, you can only do 1 ajax postback per page.

Optionally, you can create generic ASHX Http Handlers to do your form logic and use JQuery Ajax to post back to the Generic Http Handlers. In which case you can do as many of those at a time as you want.

Generally I use ASHX handler's any time I need to serve images that change, like on the fly imaging. I also use them for large data outputs. E.g. the ASHX handler returns a big dump of JSON. I do an Ajax Postback to the ASHX handler to get a set of data in JSON and append it to a table etc and I call the ASHX handler repeatedly on a timer to get new Data as it comes in (say a 5 min timer) etc.

If you gave some more context on what your trying to do I might be able to provide you with alternative solutions.

Edit: I looked at your other post you linked and I think an ASHX handler would serve you well. You can design the ASHX handler to return your Search Data in JSON. You can use Request varaibles in the ASHX handler and you can send post data to the ASHX Handler with JQuery.Ajax.

You should be able to fire off multiple requests each with it's own Success Function. Then you would need to write the javascript in such a way that as it's processing the JSON data from the ashx handler it can merge with other requests as they finish.

0

精彩评论

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

关注公众号