Microsoft KB Archive/941955

= A Web Part that contains an ASP.NET AJAX 1.0 UpdatePanel control that uses the _doPostBack function does not work when the URL of the hosting SharePoint Web site contains international characters =

Article ID: 941955

Article Last Modified on 10/10/2007

-

APPLIES TO


 * Microsoft Office SharePoint Server 2007
 * Microsoft Windows SharePoint Services 3.0

-



SYMPTOMS
Consider the following scenario:
 * You use the Microsoft AJAX 1.0 Control toolkit for Microsoft ASP.NET or the AJAX 1.0 Extensions for ASP.NET to create a custom Web Part for a Microsoft Office SharePoint Server 2007 Web site or for a Microsoft Windows SharePoint Services 3.0 Web site.
 * The custom Web Part contains an UpdatePanel control that includes a _doPostBack function, such as a LinkButton control.
 * You add the custom Web Part to a SharePoint Services 2007 Web site or to a Windows SharePoint Services 3.0 Web site. The URL of the Windows SharePoint Services 3.0 Web site or the SharePoint Server 2007 Web site contains international characters or language-specific characters.
 * You visit the Windows SharePoint Services 3.0 Web site or the SharePoint Server 2007 Web site. Then, you try to update selected content in the Web Part.

In this scenario, a regular postback request occurs instead of an asynchronous ASP.NET AJAX postback request.



CAUSE
This issue occurs because both Windows SharePoint Services and ASP.NET AJAX cache some types of form actions. Therefore, conflicts may occur.



WORKAROUND
To work around this issue, use code that resembles the following example to add an UpdatePanel control to a Web Part in SharePoint Server 2007 or in Windows SharePoint Services 3.0. private void EnsureUpdatePanelFixups {              if (this.Page.Form != null) {                  String fixupScript = @&quot; _spBodyOnLoadFunctionNames.push(&quot;&quot;_initFormActionAjax&quot;&quot;); function _initFormActionAjax {   if (_spEscapedFormAction == document.forms[0].action) {       document.forms[0]._initialAction = document.forms[0].action; } } var RestoreToOriginalFormActionCore = RestoreToOriginalFormAction; RestoreToOriginalFormAction = function {   if (_spOriginalFormAction != null) {       RestoreToOriginalFormActionCore; document.forms[0]._initialAction = document.forms[0].action; } } The following code is an example of a Web Part that includes the previous UpdatePanel control. Additionally, the EnsureUpdatePanelFixups method is used to register the Script Manager control in the Web Part. public class AjaxUpdatePanelPart : WebPart {       private Label label; private TextBox textBox; protected override void CreateChildControls {           base.CreateChildControls; this.EnsureUpdatePanelFixups; UpdatePanel up = new UpdatePanel; up.ID = &quot;UpdatePanel1&quot;; up.ChildrenAsTriggers = true; up.UpdateMode = UpdatePanelUpdateMode.Conditional; this.Controls.Add(up); this.textBox = new TextBox; this.textBox.ID = &quot;TextBox&quot;; up.ContentTemplateContainer.Controls.Add(this.textBox); this.label = new Label; this.label.Text = &quot;Enter your name.&quot;; up.ContentTemplateContainer.Controls.Add(this.label); LinkButton button = new LinkButton; button.Text = &quot;Say Hello&quot;; button.ID = &quot;HelloButton&quot;; // Some controls need an ID to make them work with AJAX postbacks. button.Click += new EventHandler(HandleButtonClick); up.ContentTemplateContainer.Controls.Add(button); }       private void HandleButtonClick(object sender, EventArgs eventArgs) {           this.label.Text = &quot;Hello &quot; + this.textBox.Text; }       private void EnsureUpdatePanelFixups {              if (this.Page.Form != null) {                  String fixupScript = @&quot; _spBodyOnLoadFunctionNames.push(&quot;&quot;_initFormActionAjax&quot;&quot;); function _initFormActionAjax {   if (_spEscapedFormAction == document.forms[0].action) {       document.forms[0]._initialAction = document.forms[0].action; } } var RestoreToOriginalFormActionCore = RestoreToOriginalFormAction; RestoreToOriginalFormAction = function {   if (_spOriginalFormAction != null) {       RestoreToOriginalFormActionCore; document.forms[0]._initialAction = document.forms[0].action; } } &quot;; ScriptManager.RegisterStartupScript(this, typeof(AjaxUpdatePanelPart), &quot;UpdatePanelFixup&quot;, fixupScript, true); }       }    }

Additional query words: MOSS MOSS2007 WSS WSS3.0

Keywords: kbtshoot kbprb kbexpertiseinter KB941955

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.