An Idiot’s guide to MOSS Custom Webpart AJAX Issues

Posted: May 9, 2007 in Technical

          All I have to say is, with the huge amount of info I found on blogs for using the MS AJAX 1.0 controls within a MOSS 2007 Web part, I found the biggest  technical issues I ran into instituting this was retarded little "details" that i simply overlooked while digging into deep technical issues. So let’s assume you have your web part coded, You may have used a blog or perhaps your own little ASP.Net 2.0 Ajax enabled web site as a guide. You bring it up and whammo it is not working. I had issues in 2 different areas as I describe below. Anyone else got any other pointers, PLEASE post them in a comment to this blog. Also, if you have not done so, read the references on the bottom of this entry. I found these helpful in getting a good base understanding of what I needed to do in getting things working. So without further ado:
     1. Web part seems to work except the AJAX calls are not being made, the entire page is being submitted.
          a. Did you include your script manager object?
               – No script manager object no ajax calls.
          b. Did you actually add you controls via the "ContentTemplateContainer.Controls.Add" function?
              – You can google the namespace to figure this out but you will need to add your controls via this function
          c. Did you correctly setup your async triggers?
          d. and….Have you actually made the changes to the Web.Config that will enable AJAX?
              – Remember there is a difference between an ASP.Net site and an AJAX enabled ASP.Net site, it is in the web.config declarations in 
                there. Without them the app will have no idea what you want it to do in terms of AJAX.
     2. AJAX calls work fine the first time, then, after that nothing works in terms of postback(AJAX or otherwise)
            – Did you put in "EnsureUpdatePanelFixups" type function and actually execute it? (See Mike Ammerlans blog for sample)
            – Double check the order which you are initializing all your controls. It is very easy to call put your code in the wrong overriden 
              function and have it get called in correct order on a first load and incorrect order on a post back as the serverside code cycles 
              through the event handlers.
     3. You get the dreaded "An unexpected error has occured" message with no further messages or logs to help you figure out what has
         gone wrong. You can modify the web config, to get MOSS to display the full "ugly" ASP.Net error messages. This displayed an error for
         me that would have NEVER found without it. To do this:

     <SafeMode MaxControls=200 CallStack=true“…

      <customErrors mode=Off/>

         a BIG thanks goes out to the blog for this information (see link below to check them out) . BTW, it is best you do this on a dev setup if at all possible. Remember, these error message will be shown to ALL users. Not exactly the best situation for a production setup. If you have to do this on a production setup, be sure to change your config file back when you are done.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s