Wednesday, March 21, 2012

Web Parts and AJAX

OK - so I understand the official line is that ASP.Net Ajax UpdatePanel does not work properly with Web Parts. However I am a little puzzled becuase I did a test and got something working fine:

I built two CONNECTED web parts - one is a simple filename provider (a textbox and an Update button) the other web part displays a flash file based on the filename specified by the first web part. I put them both inside a web part zone, and then enclosed the WHOLE web part zone inside an Ajax Update Panel. Now, when I enter a new filename inside the first web part and click its update button - the second web part loads and plays the new flash filename WITHOUT any flicker - ie it seems to work fine.

Has anyone else tried this? Have I missed something?

I realise that my test is somewhat limited in that I can't connect web parts in different web zones but even so the above technique still seems useful if its safe to use.

Comments anyone?

The way I see it the whole point of Web Parts is that you can define several areas on a page to contain them and then move them around between the areas, reorder them, change their settings, add new ones etc. This doesn't work with ASP.NET Ajax.

For what you've described above I don't see the point in using Web Parts at all, why not just a couple of controls inside an UpdatePanel?

Personally this lack of support (and no mention of when support might be re-introduced) has forced us to create a home-grown solution.


I understand what you are saying - nevertheless keeping the web parts within one zone would still allow you to reorder them within that zone, change their settings, and still allow you to connect web parts together (again within that one zone) - and those web parts could still refresh without the rest of the screen flickering because the whole zone is sitting in a single UpdatePanel. In fact for my requirements I have simulated a tab panel type display whereby each web part in that zone sits in a seperate <DIV> tag which I can hide or display at will - therefore being able to arrange web parts or drag them around is not a requirement for me.

Regardless of how useful you may/may not think it is - I just want to know whether it is "safe" to place a whole Web part Zone containing several web parts inside an UpdatePanel - as it seems to work a treat. I still get the benefit of connectable web parts with the benefits of Ajax too.


(Bumping)

Has anyone else successfully placed a web part inside an UpdatePanel and got it to work? Supposedly it used to work in an earlier CTP of Ajax but then doesn't work in the final release of Ajax? I'm just puzzled as to why it seems to work fine for me?


Despite my short rant above I have tried it and got it to work, I only really came accross problems when loading the WebPartEditor and catalogue. I guess your right if all you need is the reordering etc. then maybe thats OK. If it works I'd go for it, only drawback I can see is it might completely break in a future release.

No comments:

Post a Comment