Şu senaryoyu inceleyin:
- Microsoft AJAX 1.0 Denetim araç seti Microsoft ASP.NET veya Microsoft Windows için Microsoft Office SharePoint Server 2007 Web sitesi veya özel Web bölümü oluşturmak, ASP.NET AJAX 1.0 uzantıları için kullandığınız SharePoint Services 3.0 Web sitesi.
- Özel Web Bölümü LinkButton denetim gibi _doPostBack() yer alan bir işlev içeren bir UpdatePanel denetimi içerir.
- Özel Web Bölümü, bir Windows SharePoint Services 3.0 Web sitesi için bir SharePoint Services 2007 Web sitesi veya ekleyin. Windows SharePoint Services 3.0 Web sitesinin URL'SINI veya SharePoint Server 2007 Web sitesi, uluslararası karakterler veya dile özgü karakterler içeriyor.
- Windows SharePoint Services 3.0 Web sitesi veya SharePoint Server 2007 Web sitesini ziyaret edin. Daha sonra seçilen Web Bölümü içeriğini güncelleştirmek deneyin.
Bu senaryoda, zaman uyumsuz bir ASP.NET AJAX postback istek yerine normal postback isteği oluşur.
Bu sorun, Windows SharePoint Services'ı ve ASP.NET AJAX, bazı form eylem türlerini önbelleğe nedeniyle oluşur. Bu nedenle, çakışmaları ortaya çıkabilir.
Bu soruna geçici bir çözüm bulmak için <a0></a0>, bir SharePoint Server 2007'de veya Windows SharePoint Services 3.0 Web Bölümünü bir
UpdatePanel denetim eklemek için aşağıdaki örnek benzer bir kod kullanın.
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;
}
} aşağıdaki kod, önceki
UpdatePanel denetimi içeren bir Web Bölümü'nün bir örnektir. 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);
}
}
}