Cant get user control collection property to show up in designer

Greetings,

 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 */

[ParseChildren(true)]
[PersistChildren(false)]
public partial class Controls_TabView : System.Web.UI.UserControl
{
private string[] strings_ = new string[20];

protected void Page_Load(object sender, EventArgs e)
{

}

[Category("Test"),
Description("testing 456"),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
PersistenceMode(PersistenceMode.InnerProperty)]
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!

-skel

0
skel
7/8/2008 7:25:50 PM
asp.net.web-forms 93655 articles. 2 followers. Follow

2 Replies
388 Views

Similar Articles

[PageSpeed] 57

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.

Smile
 

 
 

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

 -skel
 

 
 

0
skel
7/14/2008 4:14:35 PM
Reply:

Similar Artilces:

Getting a web form's properties to a Custom User Control
Ok. This is hopefully a simple question that someone could help me out on. I've researched but only found out how to get a user control properties to a web form. Problem:  Anyway, I have created a custom user control (Help button with a menu extender) which will be used on several pages. The menu that extends from the button will not be static, so I will want to load the right data (from my xml file) depending on which page the help button is on. For example, my custom user control will be on pages news and the other on media. Now, when the user control loads on the news page, I need ...

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

Getting the Selected Item of dropdownlist inside Web User Control on a Web Form
Ive got a dropdownlist control inside a web user control called Entity.ascx. This web user control is on a webform.aspx. In Entity.ascx class I created a SelectedEntity property that returns the selected item in the dropdownlist. Inside webform.aspx when btnGo is pushed I set a string and pass it in the url. I am trying to get the entity they selected via the property (SelectedEntity) inside Entity.ascx. As the SelectedEntity property tries to return the selected item in the dropdownlist I get this error: System.NullReferenceException: Object reference not set to an instance...

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

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

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

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

Web User Control Design Property Window
I've made a user control and set up a property to be set at design time through the property window, but I'd like to know how to set up the property window to display a drop-down with approved options.  I've been looking into setting the attributeslist, but cannot seem to determine the appropriate way to limit the input one can pass to the property.  Does anyone know what I''m looking for?  Thanks. I'm not positive but I believe that if you set the datatype of the property to be set to an Enum with the approved values, that just might do what you are ...

Access User Control properties from a Web Form
Hello, Can someone please let me know how I can access the properties of a web form from a user control? For example, I have a user control which contains an imagebutton, and I have "attached" this to the web form using the <%@ Register tag. However I would like to control the visibility of a particular control on the web form via the user control, but am unable to find out how I can do this. Any help will be much appreciated, Thanks for your time you can access the parent page's properties by using page.property in the user control. page.controls or page.fi...

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

Web user control form design problemes
when i try to edit the design of my web user control i got an error saying that my BASE object is not set to an instance of an object ! How can i fix that thank you !! was working fine but without any changes it does that !! i use VS.net 2003 !! /////////HERE MY BASE OBJECT/////// using System; using System.Data; using System.Collections; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; namespace LNHockey { public class LeagueModuleControl : System.Web.UI.UserControl { Hashtable _se...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

cant get web user control page value
i have a page web user control (ascx file), name =criteria in the ascx page i have a dropdownlist, name = Field1 the ascx page have a function Function GetValue() as string    Return Field1.SelectedItem.text Ebd Function now i include the ascx file to my web form with button ''''button at the web form not ascx file in button click events Dim Str as String Dim objCriteria as new Criteria  ' Criteria is ascx page class name Str = objCriteria.GetValue But at runtime i get an error say null reference exception how to solve the problem? i using VS 2005 and .ne...

Set User Control Property from web form class
I am having a difficult time Setting the values of the properties in my User Control. My user control code follows: '---- tabs.ascx.vb ------------------- Public Class tabs Inherits System.Web.UI.UserControl Public tab1Name As String Public tab1href As String Public Sub New() End Sub Property t1Name() Get Return tab1Name End Get Set(ByVal Value) tab1Name = Value End Set End Property Property t1href() Get Return tab1href ...

Web resources about - Cant get user control collection property to show up in designer - asp.net.web-forms

Brogdale Farm - home of the National Fruit Collection - a great day out in Kent
Brogdale Farm, home of the National Fruit Collection Kent tourist attraction. A great day out for all the family with local produce, healthy ...

National Fruit Collection
The is one of the largest fruit collections in the world and includes over 3,500 named Apple, Pear, Plum, Cherry, Bush fruit, Vine and Cob Nut ...

Collection (museum) - Wikipedia, the free encyclopedia
A museum is distinguished by a collection of often unique objects that forms the core of its activities for exhibitions , education , research ...

The Beatles ‘1+’ collection w/ 50 restored videos now available exclusively on iTunes
Today Apple’s iTunes Store is getting some exclusive content from The Beatles with the “1+” collection consisting of 50 restored videos. The ...

NSA stops bulk collection of phone metadata
The NSA's bulk surveillance and collection of phone data has come to an end. President Obama announced that the current surveillance program ...

The LA City Council just confirmed everyone’s worst fears about license plate data collection
Everyone remember the film Minority Report that revolved around people with psychic abilities who used their powers predict crimes so that cops ...

Trump On NSA Data Collection: ‘I Err On The Side Of Security’
Trump On NSA Data Collection: ‘I Err On The Side Of Security’

Bit.Trip collection coming to PS4, PS3, Vita
... available on PlayStation systems, Sony announced today during its keynote address at the PlayStation Experience in San Francisco. The collection ...

118-Year-Old Cake Sweetens Italian Museum Collection
The tart was baked for Austria's Empress Elisabeth and is being displayed at an Italian castle she once visited.

Fashion brand Moschino is making a 'Super Mario' collection
Moschino is becoming known for sending bizarre collections down the runway, meshing interesting aspects of culture with fashion. The brand's ...

Resources last updated: 12/8/2015 12:33:49 AM