我正在创建一个复合控件类,其中包含多个 devexpress aspx 控件。但是,设计时存在一个问题:每当我更改我公开的子控件属性时,子控件都会丢失其界面/皮肤(如下图)
上图显示,leftlistbox,底部两个按钮是 aspx控件,而 rightlistbox 是 asp 控件。每当我访问并更改复合控件的子控件属性时,只有那些 devexpress 控件会在设计时丢失其界面/外观,如上所示。下面是我的复合控件类文件。
[ParseChildren(true), PersistChildren(false)]
public class CompositeControl_TEST : CompositeControl, INamingContainer
{
private ASPxListBox leftListBox;
private ListBox rightListBox;
private ASPxButton lefttoright;
private ASPxButton righttoleft;
[Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), RefreshProperties(RefreshProperties.Repaint), NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public DevExpress.Web.ASPxEditors.ASPxListBox XF_leftListBox
{
get
{
this.EnsureChildControls();
return leftListBox;
}
}
[Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), RefreshProperties(RefreshProperties.Repaint), NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public ListBox XF_rightlistBox
{
get
{
this.EnsureChildControls();
return rightListBox;
}
}
[Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), RefreshProperties(RefreshProperties.Repaint), NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public DevExpress.Web.ASPxEditors.ASPxButton XF_left2rightButton
{
get
{
this.EnsureChildControls();
return lefttoright;
}
}
[Bindable(true), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), RefreshProperties(RefreshProperties.Repaint), NotifyParentProperty(true)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public DevExpress.Web.ASPxEditors.ASPxButton XF_right2leftButton
{
get
{
this.EnsureChildControls();
return righttoleft;
}
}
protected override void RecreateChildControls()
{
base.EnsureChildControls();
}
protected override void CreateChildControls()
{
this.Controls.Add(new LiteralControl(@"<div>"));
this.Controls.Add(new LiteralControl(@"<table>"));
this.Controls.Add(new LiteralControl(@"<tr>"));
this.Controls.Add(new LiteralControl(@"<td>"));
this.leftListBox = new ASPxListBox();
this.leftListBox.ID = this.ClientID + "leftListBox";
this.leftListBox.Items.Add("left from cs");
this.Controls.Add(leftListBox);
this.Controls.Add(new LiteralControl(@"</td>"));
this.Controls.Add(new LiteralControl(@"<td>"));
this.rightListBox = new ListBox();
this.rightListBox.ID = this.ClientID + "rightListBox";
//this.rightListBox.Items.Add("Right from cs");
this.Controls.Add(rightListBox);
this.Controls.Add(new LiteralControl(@"</td>"));
this.Controls.Add(new LiteralControl(@"</tr>"));
this.Controls.Add(new LiteralControl(@"<tr>"));
this.Controls.Add(new LiteralControl(@"<td>"));
this.lefttoright = new ASPxButton();
lefttoright.ID = this.ClientID + "lefttoright";
lefttoright.Text = "lefttoright";
this.Controls.Add(lefttoright);
this.Controls.Add(new LiteralControl(@"</td>"));
this.Controls.Add(new LiteralControl(@"<td>"));
this.righttoleft = new ASPxButton();
righttoleft.ID = this.ClientID + "righttoleft";
righttoleft.Text = "righttoleft";
this.Controls.Add(righttoleft);
this.Controls.Add(new LiteralControl(@"</td>"));
this.Controls.Add(new LiteralControl(@"</tr>"));
this.Controls.Add(new LiteralControl(@"</div>"));
base.CreateChildControls();
}
}
}
我一直在网上搜索类似的问题,但似乎没有找到任何匹配的问题。