C# Sharepoint EditorPart工作不正常

C# Sharepoint EditorPart工作不正常,c#,asp.net,.net,sharepoint,.net-4.5,C#,Asp.net,.net,Sharepoint,.net 4.5,问题是apply和ok按钮不起作用 我有一些Web部件继承了EditorPart,并覆盖了CreateChildControls、ApplyChanges和SyncChanges方法。嗯,当加载控件时,调用SyncChanges方法。之后调用CreateChildControls。在我尝试通过单击apply和/或ok按钮保存更改之前,一切都很好。单击后,仅调用CreateChildControls,但不调用ApplyChanges,也不调用SyncChanges 嗯,我不知道我怎样才能纠正这种行

问题是
apply
ok
按钮不起作用

我有一些Web部件继承了
EditorPart
,并覆盖了
CreateChildControls
ApplyChanges
SyncChanges
方法。嗯,当加载控件时,调用
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();
    }
}
[AspNetHostingPermission(SecurityAction.Demand,Level=AspNetHostingPermissionLevel.Minimal)]
公共类AllBrandsEditorWP:EditorPart
{
私人住宅;
私有常量字符串\u ascpath=@“~/somepath.ascx”;
受保护的覆盖无效CreateChildControls()
{
var webPart=(所有品牌)WebPartToEdit;
if(webPart==null)返回;
var-control=(AllBrandsEditor)Page.LoadControl(_-ascpath);
control.ID=“allBrandsED”;
控件。添加(控件);
}
公共覆盖bool ApplyChanges()
{
ensureChildControl();
var webPart=(所有品牌)WebPartToEdit;
变量编辑器=(AllBrandsEditor)FindControl(“allBrandsED”);
如果(编辑器!=null)
{
webPart.SummaryLinkStore=string.Empty;
webPart.SummaryLinkStore=SummaryLinksManager.SetAll(editor.SummaryLinkStore);
}
isApply=true;
返回true;
}
公共覆盖无效同步更改()
{
如果(适用)返回;
var webPart=(所有品牌)WebPartToEdit;
if(webPart==null)返回;
变量控制=(AllBrandsEditor)FindControl(“allBrandsED”);
var store=新列表();
store.AddRange(!string.IsNullOrEmpty(webPart.SummaryLinkStore)
?SummaryLinksManager.GetAll(webPart.SummaryLinkStore)
:SummaryLinksManager.GetAll(Local.ize(“SummaryLinkStore”));
control.SummaryLinkStore=store;
控件。ShowSummaryLinks();
}
}

嗯,问题出在子Web部件中。它有
GridView
DropDownLists
AutoPostBack=true
导致回发,并且在任何回发之后外部按钮都不起作用。因此,我使用JS jQuery重写了内部Web部件,效果很好