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 93667 articles. 10 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 22

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:

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><...

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...

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. ...

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...

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...

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...

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...

Getting properties of page from user control
I have a page with two textboxes and a button. When the button is clicked I dynamically load a user control onto the same page. What would be the best technique for reading the textbox values from the page once the user control has been dynamically loaded? Thanks Simon...

How do I get the value of a user control property?
I would like to create a user control with some properties and assign values to those propeties.I would then like to access those values on the page that calls the user control.Thank you for your help. You can use the instance name of  the user control to call its properties.For example,a user control name is UserControl1 and it has the properties such as Text,Value,ListItem and so on,and you can call the properties as the following code.string strText = UserControl1.Text or UserControl1.Text = "This is a testing Text."string strValue = UserControl1.Value or UserControl...

Design View of Properties for User Controls
Hi,  I created a user control and one of the properties of that user control is HeaderText which is the text to be displayed inside a label in the user control. If I write something like:<me:mycontrol runat="server" ID="bslogin1" HeaderText="I Want To Display This Text"> </me:mycontrol> then it executes fine when I run the page or view it in a  browser, but it does not appear properly in design view.  Similarly with the Property Window - I can set the HeaderText to the value I desire but it does not change in design view. How can ...

User Controls with collection as an inner property
'alloI'm looking to create a user control in ASP.Net that, from the control declaration on a page, can accept multiple items as inner properties (all of the same type) which get added to a collection internally; something similar to how the DropDownList works.Something like:<custom:MyControl runat="server" id="ctrl1"> <items> <item name="item1" value="0" /> <item name="item2" value="1" /> </items> </custom:MyControl>Can anyone explain how this is done, and/or e...

ASP, User Controls, Collection Property
 I'm trying to create a user control that has a DropDownList control within it.  The problem is I can't find information on how to maintain the item collection property.  I would like to be able to just click on the user control, see an "Items" property with the ... button, then click the ... button to open a ListItemCollection Editor just as it would if it were a normal DDL.Any hints?Similarly, what if I wanted to have a style builder with my UC?  What I really want to get out of that is just the ability to easily modify the position to absolute, is the...

property browsing in Design view for a User Control
Hello...It's possible to have the properties of my USER CONTROL  in the Properties browser?I use this: <Browsable(True), Category("test"), Description("prueba prueba")> _ Public Property ControlDestino() Get Return strControlDestino End Get Set(ByVal Value) strControlDestino = Value End Set End Propertybut nothing happens.!Thanks a lot.! Hi,with UC on Page (design view) and VS2003, it's not supported. VS2005 does support it though.Thanks,Teemu KeiskiFinland, EU...

Cant get session state from my user control
I have a user control that has button. When I click the button i pass a string value into session state like so :- public void SubmitBtn_Click(Object sender, EventArgs e) { Session["PageToLoad"] = "UserControls/EditMailboxs.ascx"; Server.Transfer("Display_Mailboxs.aspx"); } and then as can be seen above redirect to another page or its parent page which then loads a control using the path contained in the session. Problem is that when it gets to the parent page and using :- String test = (String)Session["PageToLoad"]; ...

Getting User Control Type at Design Time
I wrote a custom extender control that exposes additional properties to the components on the design surface.  Unfortunately, UserControls have very limitied support at design-time.  When a User Control is added to the page, it is represented by an instance of System.Web.UI.UserControl as opposed to the actual class representing the UserControl in the codebehind.  I would like to get access to the properties and events of the actual UserControl class for my extender control as design-time.  I have tried Page.LoadControl but that fails at design-time.  Is there a...

how to set and get properties of user control on webform
Hi i am a newbiei just want  to know how to set and get the propeties of user control which is placed on the webform.i tried doing it by writing the properties on the user control.and but unable to set the value of the textbox.  This is my code.UserControl.ascx.cspublic string FirstName        {            get            {                return txtFname.Text;        &nbs...

Adding collection property in web user control
Hi, I have a requirement to add a collection property in web user control.So that items can be added at design time.I need some help or sample to achieve this. Try something similar to this: [PersistenceMode(PersistenceMode.InnerProperty), MergableProperty(false)]public virtual MyItemCollection Items{ get { if (this.items == null) { this.items = new MyItemCollection (); if (base.IsTrackingViewState) { this.items.TrackViewState(); } } return this.items; }} You might store y...