Sharepoint EditorPart无法正常工作

时间:2014-09-16 12:32:50

标签: c# asp.net .net sharepoint .net-4.5

问题是applyok按钮不起作用。

好吧,我有一些继承EditorPart且已覆盖CreateChildControlsApplyChangesSyncChanges方法的网站部分。好吧,当加载控件时,调用SyncChanges方法。在调用CreateChildControls之后。在我尝试通过点击apply和/或ok按钮保存更改之前,一切都很顺利。点击后,系统会调用CreateChildControls,但不会调用ApplyChanges,也不会调用SyncChanges

好吧,我不知道如何解决这个问题。请,建议。

[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AllBrandsEditorWP : EditorPart
{
    private bool isApply;

    private const string _ascxPath = @"~/somepath.ascx";

    protected override void CreateChildControls()
    {
        var webPart = (AllBrands) WebPartToEdit;
        if (webPart == null) return;
        var control = (AllBrandsEditor) Page.LoadControl(_ascxPath);
        control.ID = "allBrandsED";
        Controls.Add(control);
    }

    public override bool ApplyChanges()
    {
        EnsureChildControls();
        var webPart = (AllBrands) WebPartToEdit;
        var editor = (AllBrandsEditor) FindControl("allBrandsED");
        if (editor != null)
        {
            webPart.SummaryLinkStore = string.Empty;
            webPart.SummaryLinkStore = SummaryLinksManager.SetAll(editor.SummaryLinkStore);
        }
        isApply = true;
        return true;
    }

    public override void SyncChanges()
    {
        if (isApply) return;
        var webPart = (AllBrands) WebPartToEdit;
        if (webPart == null) return;
        var control = (AllBrandsEditor) FindControl("allBrandsED");
        var store = new List<SummaryLink>();
        store.AddRange(!string.IsNullOrEmpty(webPart.SummaryLinkStore)
            ? SummaryLinksManager.GetAll(webPart.SummaryLinkStore)
            : SummaryLinksManager.GetAll(Local.ize("SummaryLinkStore")));
        control.SummaryLinkStore = store;
        control.ShowSummaryLinks();
    }
}

1 个答案:

答案 0 :(得分:0)

嗯,问题出在儿童网站上。它有GridView DropDownListsAutoPostBack=true导致回发,并且在任何回发外部按钮不起作用之后。所以我用JS-jQuery重写了内部webpart,它运行正常。