Microsoft Knowledge Base Email Alertz

KBAlertz.com: 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

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]

Search KbAlertz

Advanced Search

Webmasters
Put kbAlertz on your website.
[ Click Here for more! ]





ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **


Community Site



We Send hundreds of thousands of emails using ASP.NET Email


ASP.NET 3.5 Web Hosting with Windows 2008 and SQL 2008: Click Here!
Discount ASP.NET Hosting
ASP.NET 2.0 and 3.5
Windows2008 and SQL2008
US and UK Hosting
KBAlertz referrals get
** SIX MONTHS FREE **




Mentioned In








Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks




Article ID: 941955 - Last Review: October 10, 2007 - Revision: 1.1

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

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 = @"
_spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
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 = "UpdatePanel1";
            up.ChildrenAsTriggers = true;
            up.UpdateMode = UpdatePanelUpdateMode.Conditional;
            this.Controls.Add(up);
            this.textBox = new TextBox();
            this.textBox.ID = "TextBox";
            up.ContentTemplateContainer.Controls.Add(this.textBox);
            this.label = new Label();
            this.label.Text = "Enter your name.";
            up.ContentTemplateContainer.Controls.Add(this.label);
            LinkButton button = new LinkButton();
            button.Text = "Say Hello";
            button.ID = "HelloButton";  // 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 = "Hello " + this.textBox.Text;
        }
        private void EnsureUpdatePanelFixups()
        {
               if (this.Page.Form != null)
               {
                   String fixupScript = @"
_spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
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;
    }
}
";
                ScriptManager.RegisterStartupScript(this, typeof(AjaxUpdatePanelPart), "UpdatePanelFixup", fixupScript, true);
            }
        }
    }

APPLIES TO
  • Microsoft Office SharePoint Server 2007
  • Microsoft Windows SharePoint Services 3.0
Keywords: 
kbtshoot kbprb kbexpertiseinter KB941955
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate

Be the first to leave feedback, to help others about this knowledge base article.

(Optional) Name

(Optional) Public URL Or Email

Comments
No HTML -- Text Only Please