473,657 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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: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?
Feb 14 '06 #1
1 6096
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?

Feb 15 '06 #2

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

Similar topics

5
6908
by: mtv | last post by:
Hi all, I have the following code: ================================ Webservice side: public class MyWS: WebService { private myLib.DataObject curDataObject;
0
1323
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 structure. The template items describe how each particular note type of the tree should be rendered (the nodes are data capture elements - bool string and more complicated things). I don't want to use ViewState because of size (there are...
19
4906
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 exception of custom Collection Classes. Background: I'm developing an A2K .mdb to be deployed as an .mde at my current job-site. It has several custom controls which utilize custom classes to wrap built-in controls, and add additional functionality....
14
14635
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 so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
8
11965
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 which is not a string, for example a custom type Address which contains properties such as StreetAddress, City, County, Country etc how do i bind to those properties on the same form view? I have tried doing Bind("Address.StreetAddress") but...
11
10125
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 seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
7
10909
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: <Expander Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type res:CustomResources}, ResourceId=CustomExpanderStyle1}}" >
5
4109
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 to wrap the control in the proper control type - which is also a container. At design time I want to be able to turn this : <my:container> <asp:textbox />
4
2476
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 unsuccessfully in creating the whole pane as a user control and have succeeded in adding the pane and then dynamically adding the content which is a user control to the pane, dynamically within the page. However I would like to have a single pane...
0
8395
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8826
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.