473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Custom Control with a complex property type

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:MyControl id="MyControl6" runat="server" Height="32px" Width="152px"
ControlList="WebControl[] Array"></myasp:MyControl>

What I want is for the ControlList property to serialize something like:

<myasp:MyControl id="MyControl6" runat="server" Height="32px" Width="152px">
<ControlList>
<asp:linkbutton id="LinkButton1"
runat="server">LinkButton</asp:linkbutton>
<asp:imagebutton id="ImageButton1" runat="server"></asp:imagebutton>
<asp:button id="Button1" runat="server" Text="Button"></asp:button>
<asp:hyperlink id="HyperLink1"
runat="server">HyperLink</asp:hyperlink>
<asp:label id="Label1" runat="server">Label</asp:label>
</ControlList>
</myasp:MyControl>

Is this possible?
Feb 14 '06 #1
1 6087
I've solved the first issue by adding the following attribute to my custom
property:

[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)]

This causes the html in my aspx page to look like:

<myasp:MyControl id="MyControl1" runat="server" Width="88px" Height="266px">
<ControlList>
<asp:Button ID="frmControlButton0"></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.WebControls.WebControl
{
private System.Web.UI.WebControls.WebControl[] pControls_m = null;

[Category("Appearance"),DefaultValue(""),
Editor(typeof(ControlListEditor),
typeof(System.Drawing.Design.UITypeEditor))]
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content),
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.WebControl[] ControlList
{
get
{
return pControls_m;
}
set
{
pControls_m = value;
}
}
}
"Jeremy Chapman" <please@Idontlikespam> wrote in message
news:%2***************@TK2MSFTNGP09.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:MyControl id="MyControl6" runat="server" Height="32px"
Width="152px" ControlList="WebControl[] Array"></myasp:MyControl>

What I want is for the ControlList property to serialize something like:

<myasp:MyControl id="MyControl6" runat="server" Height="32px"
Width="152px">
<ControlList>
<asp:linkbutton id="LinkButton1"
runat="server">LinkButton</asp:linkbutton>
<asp:imagebutton id="ImageButton1"
runat="server"></asp:imagebutton>
<asp:button id="Button1" runat="server" Text="Button"></asp:button>
<asp:hyperlink id="HyperLink1"
runat="server">HyperLink</asp:hyperlink>
<asp:label id="Label1" runat="server">Label</asp:label>
</ControlList>
</myasp:MyControl>

Is this possible?

Feb 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mtv | last post by:
Hi all, I have the following code: ================================ Webservice side: public class MyWS: WebService { private myLib.DataObject curDataObject;
0
by: Iain | last post by:
Can I apologise for the lengthy nature of this post. The scenario is complicated (though I hope the solution is not!) basically, I've got a custom template control which binds itself to a tree...
19
by: Jamey Shuemaker | last post by:
I'm in the process of expanding my knowledge and use of Class Modules. I've perused MSDN and this and other sites, and I'm pretty comfortable with my understanding of Class Modules with the...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
8
by: =?Utf-8?B?QXNo?= | last post by:
Hi, I have an object, for example User. User contains various properties which i have been able to bind to successfully using wizards and the form view. However if the class User has a property...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
7
by: Linda Liu[MSFT] | last post by:
Hi George, I have downloaded your sample solution and built it on my machine. I got a compilation error indicating that the type of "CustomResources" doesn't exist in the following xaml code: ...
5
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.