I've solved the first issue by adding the following attribute to my custom
property:
[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
NotifyParentPro perty(true),
PersistenceMode (PersistenceMod e.InnerProperty )]
This causes the html in my aspx page to look like:
<myasp:MyContro l id="MyControl1 " runat="server" Width="88px" Height="266px">
<ControlList>
<asp:Button ID="frmControlB utton0"></asp:Button>
</ControlList>
</myasp:MyControl >
But now, if I close my web form and re-open it, Visual studio can't create
the control on my page, I get an error '' could not be set on property
ControlList. What does this mean?
Here is the relevant code to my control:
[DefaultProperty ("ControlList") ,
ToolboxData("<{ 0}:MyControl runat=server></{0}:MyControl>" )]
public class MyControl : System.Web.UI.W ebControls.WebC ontrol
{
private System.Web.UI.W ebControls.WebC ontrol[] pControls_m = null;
[Category("Appea rance"),Default Value(""),
Editor(typeof(C ontrolListEdito r),
typeof(System.D rawing.Design.U ITypeEditor))]
[DesignerSeriali zationVisibilit y(DesignerSeria lizationVisibil ity.Content),
NotifyParentPro perty(true),
PersistenceMode (PersistenceMod e.InnerProperty )]
public System.Web.UI.W ebControls.WebC ontrol[] ControlList
{
get
{
return pControls_m;
}
set
{
pControls_m = value;
}
}
}
"Jeremy Chapman" <please@Idontli kespam> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
I have a property will an array of webcontrols.
The control features a custom property editor which can add and remove web
controls to the array, but how do I persist the informtion by serializing
it to the aspx page?
For example, right now, here is what the html looks like when I drag my
control on to the page and add some web controls to the ControlList
property:
<myasp:MyContro l id="MyControl6 " runat="server" Height="32px"
Width="152px" ControlList="We bControl[] Array"></myasp:MyControl >
What I want is for the ControlList property to serialize something like:
<myasp:MyContro l id="MyControl6 " runat="server" Height="32px"
Width="152px">
<ControlList>
<asp:linkbutt on id="LinkButton1 "
runat="server"> LinkButton</asp:linkbutton>
<asp:imagebutto n id="ImageButton 1"
runat="server"> </asp:imagebutton >
<asp:button id="Button1" runat="server" Text="Button"></asp:button>
<asp:hyperlin k id="HyperLink1 "
runat="server"> HyperLink</asp:hyperlink>
<asp:label id="Label1" runat="server"> Label</asp:label>
</ControlList>
</myasp:MyControl >
Is this possible?