I have been wondering a long time how to do a public property for a User Control that work\'s like .NET native Item\'s collection Property (for Example, ListBox and ListItem
Just as an add on - the link above really helped. The only thing that I want to add is how you can directly register it in your website so that intellisense picks it up and without having a different assembly.
Create the classes as described - instead if the rendering i override the OnInit method, since it is called earlier and I can play some more with the other prop. Create 2 namespaces:
namespace x.Controls.Conference - add the class that derives from UserControl
{
public partial class SlideShow : System.Web.UI.UserControl{...}
}
namespace x.Controls.Conference.SlideShowUC - add here the base class of the collection item in the UC (Collection)
{
public class Slide{...}
public class SlideCollectionEditor : CollectionEditor{...}
}
Now you can directly register them in your aspx pages or in the web config, depending on how often you will use the control.
WEB CONFIG
PAGE
<%@ Register TagPrefix="ucSlideShow" TagName="SlideShow" src="~/x/Controls/Conference/SlideShow.ascx" %>
<%@ Register TagPrefix="ucSlideShow" namespace="x.Controls.Conference" assembly="WebAssembly" %>