Friday, September 21, 2007

Ajax in MOSS via the Update Panel

I'm currently doing a lot of ASP.NET development inside MOSS 2007. On this current project we've been doing the most of our RAD outside of SharePoint and then porting our ASP.NET application inside a MOSS instance for integration. Needless to say, like so many developers working with MOSS, I've had an interesting time troubleshooting a litany of errors that seem to come up working inside this new framework.

Today's save comes from Mike Amerlaan who's figured out a fairly critical hint that's needed to get Update Panel's to work inside a MOSS site.

Prior to discovering Mike's fix I would be able to post back (inside an update panel) ONCE after which all postback's on the page became non functional.

Essentially this is because WSS emits submit wrapping javascript that tampers with how your page submits. It does this to ensure that urls that involve double byte (read unicode) characters post back appropriately.

To get your update panels working you're going to have to remove this script. You can disable it by emitting the following javascript:

spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;

You can of course do this by using either the ScriptManager or the Page.ClientScript.RegisterStartupScript. I'm pretty sure you'll be able to figure the rest out.

Besides that you pretty much do what you would expect to do to get UpdatePanel's working inside MOSS.

  1. Install the Ajax extensions on the host machine
  2. Migrate the web.config settings that tee up all the ajax controls/http handlers/http modules
  3. Add a tag to each page (or master page) that you want to use it in.
  4. Add you update panels around some postback event.
And that's it! Voila you're done. Now your MOSS site feels a little bit less like a stock MOSS site.

Happy Coding,


Anonymous said...

Stupid article.

How the hell are people supposed to know how to do the following?

Just because you know it doesn't mean crap to the rest of us

* Migrate the web.config settings that tee up all the ajax controls/http handlers/http modules

* Add you update panels around some postback event.

Anonymous said...

This was the solution to my problem. Thanks!

Anon: I think the being clueless is just on you. Try reading the documentation of the tools you are trying to use. It's a pretty common way to get started. If thats too much, perhaps you could write your own ajax framework, I hear the community needs another one of those.