Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Custom control with complex property type (System.Web.UI.Control[])

Reply
Thread Tools

Custom control with complex property type (System.Web.UI.Control[])

 
 
Jeremy Chapman
Guest
Posts: n/a
 
      02-15-2006
I've built a control with a property of type System.Web.UI.Control[]. I
have a custom editor which allows me to add items to this collection at
design time, and the property has persistance so that it serializes in the
aspx html correctly. My problem is that when I run my application that
contains my control, I get the following compilation error:

Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.
Compiler Error Message: CS1586: Array creation must have array size or array
initializer

the aspx html for my control looks like the following, which I think is
correct:

<myasp:MyControl id="MyControl1" runat="server" Height="130px"
Width="200px">
<ControlList>
<asp:Button ID="frmMyControlButton0" Text="test1"></asp:Button>
<asp:HyperLink ID="frmMyHyperLink1">test2</asp:HyperLink>
</ControlList>
</myasp:MyControl >


Also, If I close my aspx page in visual studio and re open it, my control is
replaced by an "Error creating control" message, and the tool tip says ''
could not be set on property ControlList. It would seem that my control can
not deserialize the html back into an object. How can I get this to work?

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.Control[] ControlList
{
get
{
return pControls_m;
}
set
{
pControls_m = value;
}
}
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating custom controls out of more complex control types (eg change password control) ryan.d.rembaum@kp.org ASP .Net Building Controls 0 02-14-2007 01:25 AM
wsdl2java: method parameter a complex type that extends another complex type Robert Mark Bram Java 0 02-04-2007 10:06 AM
Custom Control with a complex property type Jeremy Chapman ASP .Net 1 02-15-2006 12:35 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
Custom Attributes (AttributeTargets.Property) and Property Type Zarko Gajic ASP .Net Building Controls 0 04-07-2005 02:20 PM



Advertisments