Working with Ajax on MOSS 2007

0.00 avg. rating (0% score) - 0 votes

Working on ajax sucks at times even now. Now means using SP1 for MOSS 2007. For instance, if you develop a custom page and using the update panel for asp.net calendar control will not produce partial page post backs. I have came across this issue and spent a lot of time figuring out the issues. Finally, the following seems to make everything work for me. Try your luck 🙂

Working on ajax sucks at times even now means even with SP1 of MOSS 2007. Facing issues with some of the controls not producing partial page postbacks will take you to this MS knowledge base:

Microsoft Knowledge Base Article

The above knowledge base may help you a little bit, it is regarding creating updatepanel and controls dynamically meaning programatically instead of going for design time controls.

Apart from above solution, the following is a solution that really works. If you have put your controls in update panel and partial page postbacks are not working for some of the controls specially for controls like link button. The following solution surely works.

Follow these steps to make it work:

Step 1

Modify web.config <authorizedTypes> section to include all related assmebly references, so that it looks similar to that:

<authorizedTypes>
<authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35? Namespace=”System.Workflow.*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35? Namespace=”System.Workflow.*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35? Namespace=”System.Workflow.*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowActivationProperties” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowTaskProperties” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowHistoryEventType” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint.WorkflowActions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.WorkflowActions” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35? Namespace=”System.Workflow.*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35? Namespace=”System.Workflow.*” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowActivationProperties” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowTaskProperties” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.Workflow” TypeName=”SPWorkflowHistoryEventType” Authorized=”True” />
<authorizedType Assembly=”Microsoft.SharePoint.WorkflowActions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” Namespace=”Microsoft.SharePoint.WorkflowActions” TypeName=”*” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”Guid” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”DateTime” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”Boolean” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”Double” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”String” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Collections” TypeName=”Hashtable” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Collections” TypeName=”ArrayList” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Diagnostics” TypeName=”DebuggableAttribute” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Runtime.CompilerServices” TypeName=”CompilationRelaxationsAttribute” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Runtime.CompilerServices” TypeName=”RuntimeCompatibilityAttribute” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”Int32? Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System” TypeName=”TimeSpan” Authorized=”True” />
<authorizedType Assembly=”mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089? Namespace=”System.Collections.ObjectModel” TypeName=”Collection`1? Authorized=”True” />
</authorizedTypes>

Step 2

You will need to modify the master page, edit master page using Sharepoint designer. A javascript method will be called on onload. You need to remove this call so that your body tag looks like:

<body>

instead of:

<body onload=”javascript:if (typeof(_spBodyOnLoadWrapper) != ‘undefined’) _spBodyOnLoadWrapper();”>

Step 3

We will need to modify javascript method _spFormOnSubmitWrapper() which is called on Form post in your master page, this method is found in init.js file. init.js file is  installed with MOSS 2007 on server. The file is located at: Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033.

Open the file and go to method _spFormOnSubmitWrapper(), the following code will be found in the file:

if (_spSuppressFormOnSubmitWrapper)
{
return true;
}
if (_spFormOnSubmitCalled)
{
return false;
}

Replace the above code with the following code:

if (_spSuppressFormOnSubmitWrapper)
{
return true;
}
if (_spFormOnSubmitCalled)
{

}

Note that “return false” statement has been commented out. This will make ajax calls to work properly. This line is commented out because if the page is already posted back, sharepoint does not post it back again. For ajax to work properly, it is required to disable it so that partial postbacks work for every server call.

0.00 avg. rating (0% score) - 0 votes

W@rfi

Owner of this blog site. Have expertise on Microsoft technologies.

You may also like...

1 Response

  1. RaiulBaztepo says:

    Hello!
    Very Interesting post! Thank you for such interesting resource!
    PS: Sorry for my bad english, I’v just started to learn this language 😉
    See you!
    Your, Raiul Baztepo

Leave a Reply

Your email address will not be published. Required fields are marked *