问题是apply
和ok
按钮不起作用。
好吧,我有一些继承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();
}
}
答案 0 :(得分:0)
嗯,问题出在儿童网站上。它有GridView
DropDownLists
与AutoPostBack=true
导致回发,并且在任何回发外部按钮不起作用之后。所以我用JS-jQuery重写了内部webpart,它运行正常。