Cant get user control collection property to show up in designer



 I'm trying to create an ASP.NET user control that will expose a collection of objects as a property. As a proof of concept, I'm simply trying to implement a test control that contains an array of strings, and I'm attempting to enable design-time editing of the property. No matter what I seem to do, my test property doesn't show up in the designer window. Below is a code snippet...


/* using directives omitted for brevity */

public partial class Controls_TabView : System.Web.UI.UserControl
private string[] strings_ = new string[20];

protected void Page_Load(object sender, EventArgs e)


Description("testing 456"),
public string[] Strings
get{return strings_;}

 I'm trying to boil the idea down to it's simplest form; my eventual solution will use a generic container (i.e. List<>) to host the collection, but I can't even get it to work for this basic design.

 Thanks for any assistance you can lend!


Reply skel 7/8/2008 7:25:50 PM 93655 articles. 28 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 11

Is it an issue with the class-level attribute declarations, or maybe the property-level attributes are incorrect? I've made the property get-only, so that shouldn't be the problem. 

I can't believe I'm the only one to have ever run into this; someone out there must know the answer.



Reply skel 7/9/2008 12:13:04 PM

In case anyone runs into this same issue, I found that exposing an object collection as a property isn't applicable when developing ASP.NET user controls (i.e. the files with the .ascx extension). If you want to create a component with this type of behavior, you should instead be working with ASP.NET custom controls, which derive from the Control or WebControl classes.



Reply skel 7/14/2008 4:14:35 PM
Similar Artilces:

Getting value of a property in Parent User control from a Child user control
I have a ChildUserControl that is loaded inside a ParentUserControl. The host page loads ParentUserControl.I would need to access properties in ParentUserControl from the ChildUserControl.Thanks for your time Here's some ideas: You can from the child access the parent and run findcontrol. child.parent.findcontroL("indyanguy1") child.parent.parent.findcontrol("indyanguy1") The trick is when you get your findcontrol working to cast the result to the object type your looking forHere I'm looking for a label so I cast to label then I can use the .Text property.Y...

Adding a property to a user control, setting property at design time, then using value in control markup
 I have made a custom control that outputs a bunch of html. I have added a property through the code behind like this:  private string sectionID; public string SectionID { get { return sectionID; } set { sectionID = value; } } This property is now showing up in Intellisense, and I can specify the value when adding the control to my page like this: <ccl:MyControl runat="server" SectionID="2" /> I now want to use this value in the markup that the control outputs. I thi...

How Do I: (1) Show an image in the design time view of my control? (2) Have a controls property be a drop down list at design time?
I'm currently writing my first custom server control and could use a couple of pointers:First off I would like to have my control show an image in its design time view rather than the generic grey box with text in it.Secondly I have a property for my control that can be changed at design time via the properties menu.... at the moment the designer types in a value under the controls properties... I would like a drop down list displayed in the properties with all the available options in it, Any pointers in these directions would be greatly appreciated.    Cheers. ...

User Control inside a FormView- Cant access GET/SET properties
I have a user control where I have a formview and a table.  The table has two text boxes.  I want to write GET/SET properties for these textboxes so they are available to use on my default.aspx page.  Here is the code for user control: <%@ Control Language="VB" AutoEventWireup="false" CodeFile="ucSum.ascx.vb" Inherits=ucSum" %> <asp:FormView ID ="fv1" runat = "server"> <itemTemplate> <Table border="0" cellpadding="0">   <TR>     <TD> <asp:TextBox ID ="txtRent" runat="server"></asp:Textbox></TD><...

Get page controls property in User control
I have a aspx page and there is a button. I want to access this button properties in my User control. How can I do so.Yes the user control is on my aspx page You can find the button with the FindControl method. Button btnFoo = (Button)Page.FindControl("buttonId"); string id =;Please remember to click “Mark as Answer” so I know if my answer was good enough for you. Thanks.  this does not work. It returns me null.To be clear button is on my web page aspx and want to access its properties on the user control ascx Is you button nested in other controls? (eg...

web control collection property with each object in collection having a collection property
I have been trying to build a web control with a collection property and each object in the collection having its own collection property. It needs to be a nested collection with in the control. I am able to successfully create a collection property with in the control, use the collection editor to add “layers” and I am also able to create a collection property for each “layer” and add “symbols” to the “Symbols” collection. My problem lies in getting the control to write the html code for the control so that it can be parsed. Something that would look like this: <cc1:MapLayerList id="Map...

Custom Controls: Getting 'Collections' ansd 'SQL Query builder' in designer properties
I have a custom control.  How do you declare variables or methods that store Collections for a dropdownlist and the datasource and query strings for data bound controls in the Class file so that they are available in the designer mode as with asp:gridview etc. My current code allows me to fill in 'queryString' and 'number' in the designer but only as free text. I would like my control to make use of the built-in query designer and collections tools to populate and configure them.My Code.  C#::public partial class controls_Telephone : System.Web.UI.UserControl{    pub...

Can a user control have designer for design time resizing of user control?
I am trying to add desinger to user control. I wish to resize the user control at design time. I think User control doesn't have any size of it's own at design time since it doesn't have Width and Height property. Hence we can't have designer to user control at design time. Can any please confirm this? Thanks! Radix  u can use a panel to wrap your controls and give the panel fixed width and height which 3are available by drag drop design time too.Don't forget to click "Mark as Answer" on the post that helped you.Regards,Amr Elsehemyblog amrelse...

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

User control with Property to connect to other user control
Hi,I'm a bit a newb to ASP.NET ;)I want to create a user control which can be connected to another user control. So I did the following:   Private IntBreadcrumbsControl As MenuControl <Category("CMS"), Description("Set the MenuControl that displays the breadcrumbs"), Browsable(True)> _ Public Property BreadcrumbsControl() As MenuControl Get Return IntBreadcrumbsControl End Get Set(ByVal value As MenuControl) IntBreadcrumbsControl = value End Set End Property Unfortunat...

Get user input from dynamic created control, why i cant get the value???
Hi!, i was tried to dynamically generate some textboxes according the selected number in a dropdownlist, but when i need to get the user input from those textboxes.. i cant get at all!!, Can any1 guide me on tis? Below is my code.Basically, i have 1 dropdownlist (ddltbCount), 1 placeHolder(Pholder1), 1 button(btGetValue), i dont know y i cant post the html here... Private count As Integer = 1 Sub IterateThroughChildren(ByVal parent As Control) For Each c As Control In parent.Controls If c.GetType.ToString.Equals("System.Web.UI.WebControls.TextBox") AndAlso c.ID Is Nothing Then ' CType(c, T...

User Control Property Persistence
I have a user control that's rendered in a data bound List View, for example:<asp:ListView ID="ListBuildings" DataSourceId="ListDataSource" runat="server"><ItemTemplate>    <custom:Rater ID="Rater" BuildingId='<%# Eval("BuildingId")%>' runat="server" /></ItemTemplate></asp:ListView> I set a custom property on my user control called BuildingId, but on post backs I'm not finding the BuildingId property set to what I set it to in the through the list view's databind...

Can't get property from a User Control inside a Repeater control
I have a public property inside my usercontrol which I set inside the Repeater.ItemDataBound event as follows:<code>If blnFirstTime Then            Dim lblstrDate As Label = DirectCast(e.Item.FindControl("lblPressReleaseDate"), Label)            blnFirstTime = False            strDate = lblstrDate.Text        End If</code>After the user control finishes databinding, I want to take th...

User control properties in Designer
I am Using VS2005-SP1 with XP Workstation and 2003 Server (Map drive for development). If I have a Web Form and place a Server Control, Custom Server Control and a User Control on the page, I can access all the properties and Events of the Server Control, Custom Control, but not the User Control. The Custom Control fires an IntelliSense error - “Not a known element”, maybe because it was written for ASP.NET 1.x , ??? But the User Control also fires an IntelliSense error - “Not a known element”, and the property windows is displayed like “<TagName>” with no properties shown, even tho...

User Controls: How to change the Property of a User Control in CodeBehind???
Hi I am using the book "ASP.NET Unleasd" to learn ASP.NET. In Chapter 5 it talks about User Controls.  I am currently working on "Listing 5.7": Exposing properties and Methods in user controls.Well, I am trying to implement this code in visual studio using codebehind.In the user control (HeaderTitle.ascx) I have the following:<html><head><title><%=PageTitle%></title></head><body><h2>Global Super Company</h2><i>We mean business</i><hr>In the file HeaderTitle.ascx.cs (code behind for the user control) I have the ...

user control
testUserControl.ascx  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="testUserControl.ascx.cs" Inherits="testUserControl.testUserControl" %> <asp:Label ID="Label1" runat="server" Text="User control label"></asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />  testUserControl.ascx.csusing ...

Accessing properties of user control inside user control
I have a simple MemberPhoto user control which has a photo of a member along with username and if they are online.I would like to reuse this control inside of another user control (MemberSummary) that would include the member's photo and some basic information about the member.  I would like to know what is the "Best Practice" to set/read properties on the member photo control from a web form.1. Should the MemberSummary define a property that returns the MemberPhoto user control and there I would have access to th...

Getting user control property
I have several (same) usercontrols on my page. The user control consists of a checkbox and a textbox.I want to count the amount of user controls that has a checked checkbox, because this amount may not exceed 4.I have a property IsChecked in my usercontrol.There's also a OnCheckedChanged event. This is where I want to check whether the amount of checked usercontrols exceeds 4, because if it does, the check is not allowed...How can I achieve this? Can I access the page containing the usercontrols in some way? or other suggestions?please mark answers as 'Answered' and post ba...

Problem while try to set public property of user control at design time , Its happen due to UpdatePanel Control(Ajax)
Hi I have put my user control's content in Update Panel(To get Ajax Benefit) and I have register this User control in my page.  I have exposed one public property of user control in which I am trying set one textbox enable, As this property is public I am try to set its value from design time from my pagewhen I run this code its give me run time error Object Ref. not set for textbox while Public Property set its value.  If I Remove Update Panel from my user control its work properly kindly help me to solve this Problem.  //User Control Source File  <%@ Contr...

Select from control list in Design Mode for my Web User Control(e.g. same functionality as the ControlToValidate property in RequiredFieldValidator).
I’ve created a Web User Control. I would like to list all of my controls on the page in one of the properties of my Web User Control. It should have the same functionality as the RequiredFieldValidator.ControlToValidate property. Is this possible? Thanks Johan No, your web user control on the same page, then u can not access the controls of that page. Amit Thanks & Regards,Amit Batra With apologies to Amit, I say it can be done. 1. The User Control is a class. Any public property you add to that class can appear in the Property Editor. So create a public propert...

Image on User control not showing on page using user control.
I have a user control under the folder ~/Common/Controls. The user control has a table. I want to set the table row background. The images for the background are being stored under ~/Common/Images. The page that used the user control is in ~/Front/FrmHome.aspx. Now, if I specify the background as background="../Images/bk.gif", the background shows in the user control but not on the page using the user cintrol as expected. If I specify the background as background="/MyWebProject/Common/Images/arrow1.jpg", it shows fine in the user control but doesn't show up agai...

Reading Parent User COntrol Property from Child User Control
Hi Guys, I've got a child user control inside a parent user control which is included onto an aspx. I set a property on the aspx for the parent user control and I need that property to be read by the child user control. How do I go about doing that? Thanks As a quick hack you could use the Parent property of your child control to get a reference to its parent control, do a proper casting, and then access any public properties/methods in the parent control; this assumes your child control is always a child of the same type, ie: [C#] ParentControlType = (ParentControlType)thi...

User Control A needs to access a User Control B property
Greetings, I have a situation where one user control (A) needs to access a property that is exposed by another user control (B) on the same page.  I would like for user control A to access B's property directly and not have the parent page involved. How can this be done? Thanks, BCB try this using System.Web.UI.UserControl; public class A : System.Web.UI.UserControl {        private void Page_Load(object sender, System.EventArgs e)        {        &nb...

Adding Properties on User Control to Designer
I'm creating a base user control class for my project that inherits from User Control. All the user controls that I use in my project will inherit from this base class. The class that defines the base class is in the same web project as all my other files. How can I attribute a property on a base class property definition such that the property will show up in the designer. How can I tell the designer to allow only True or False? When does this property actually get set during the life cycle of the control? I've tried the following but the property still does not show up in the des...