文章編號: 941955 - 上次校閱: 2007年10月10日 - 版次: 1.1

網頁組件包含使用 _doPostBack() 函式的 ASP.NET AJAX 1.0 UpdatePanel 控制項無法運作當裝載 SharePoint 網站的 URL 包含國際字元

系統提示本文適用於您使用的作業系統之外的作業系統。與您不相關的文章內容已停用。
全部展開 | 全部摺疊

徵狀

考慮下列案例:
  • 您使用 Microsoft AJAX 1.0 控制工具組,如 Microsoft ASP.NET 或 AJAX 1.0 擴充程式的 ASP.NET 建立自訂網頁組件的 Microsoft Office SharePoint Server 2007 網站或 Microsoft Windows SharePoint 服務 3.0 的網站。
  • 自訂網頁組件包含 UpdatePanel 控制項,其中包括如 LinkButton 控制項的 _doPostBack() 函數。
  • 到 SharePoint 服務 2007年網站或為 Windows SharePoint 服務 3.0 的網站,您可以新增自訂的網頁組件。Windows SharePoint 服務 3.0 網站的 URL 或 SharePoint Server 2007 Web 網站包含國際字元或特定語言的字元。
  • 您造訪 Windows SharePoint 服務 3.0 網站或 SharePoint Server 2007 Web 站台。然後,您嘗試更新 [網頁組件] 中選取的內容。
在這種情況下一般回傳要求發生而不是非同步 ASP.NET AJAX 回傳要求。

發生的原因

之所以發生這個問題,是因為 Windows SharePoint 服務與 ASP.NET AJAX 快取某些類型的表單的動作。因此,可能會發生衝突。

其他可行方案

若要解決這個問題,使用類似下列範例將 UpdatePanel 控制項新增至網頁組件在 SharePoint Server 2007 或 Windows SharePoint 服務 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;
    }
}
下列的程式碼是包含先前 UpdatePanel 控制項的網頁組件的範例。 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);
            }
        }
    }

這篇文章中的資訊適用於:
  • Microsoft Office SharePoint Server 2007
  • Microsoft Windows SharePoint Services 3.0
關鍵字:?
kbmt kbexpertiseinter kbtshoot kbprb KB941955 KbMtzh
機器翻譯機器翻譯
重要:本文是以 Microsoft 機器翻譯軟體翻譯而成,而非使用人工翻譯而成。Microsoft 同時提供使用者人工翻譯及機器翻譯兩個版本的文章,讓使用者可以依其使用語言使用知識庫中的所有文章。但是,機器翻譯的文章可能不盡完美。這些文章中也可能出現拼字、語意或文法上的錯誤,就像外國人在使用本國語言時可能發生的錯誤。Microsoft 不為內容的翻譯錯誤或客戶對該內容的使用所產生的任何錯誤或損害負責。Microsoft也同時將不斷地就機器翻譯軟體進行更新。
按一下這裡查看此文章的英文版本:941955? (http://support.microsoft.com/kb/941955/en-us/ )
Microsoft及(或)其供應商不就任何在本伺服器上發表的文字資料及其相關圖表資訊的恰當性作任何承諾。所有文字資料及其相關圖表均以「現狀」供應,不負任何擔保責任。Microsoft及(或)其供應商謹此聲明,不負任何對與此資訊有關之擔保責任,包括關於適售性、適用於某一特定用途、權利或不侵權的明示或默示擔保責任。Microsoft及(或)其供應商無論如何不對因或與使用本伺服器上資訊或與資訊的實行有關而引起的契約、過失或其他侵權行為之訴訟中的特別的、間接的、衍生性的損害或任何因使用而喪失所導致的之損害、資料或利潤負任何責任。