Missing Intellisense While Describing Custom Control Properties Declaratively

Posted by Albert Bori on Stack Overflow See other posts from Stack Overflow or by Albert Bori
Published on 2010-05-21T21:51:22Z Indexed on 2010/05/21 22:00 UTC
Read the original article Hit count: 307

So, I've been working on this project for a few days now, and have been unable to resolve the issue of getting intellisense support for my custom-defined inner properties for a user control (ascx, mind you).

I have seen the solution to this (using server controls, .cs mind you) many times. Spelled out in this article very well. Everything works for me while using ascx controls except intellisense.

Here's the outline of my code:

[PersistChildren(true)]
[ParseChildren(typeof(BreadCrumbItem))]
[ControlBuilder(typeof(BreadCrumbItem))]
public partial class styledcontrols_buttons_BreadCrumb : System.Web.UI.UserControl
{
    ...

    [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
    public List<BreadCrumbItem> BreadCrumbItems
    {
        get { return _breadCrumbItems; }
        set { _breadCrumbItems = value; }
    }

    ...

    protected override void AddParsedSubObject(object obj)
    {
            base.AddParsedSubObject(obj);
            if (obj is BreadCrumbItem)
                    BreadCrumbItems.Add(obj as BreadCrumbItem);
    }

    ...

    public class BreadCrumbItem : ControlBuilder
    {
        public string Text { get; set; }
        public string NavigateURL { get; set; }

        public override Type GetChildControlType(string tagName, System.Collections.IDictionary attribs)
        {
            if (String.Compare(tagName, "BreadCrumbItem", true) == 0)
            {
                return typeof(BreadCrumbItem);
            }
            return null;
        }
    }
}

Here's my mark up (which works fine, just no intellisense on the child object declarations):

<%@ Register src="../styledcontrols/buttons/BreadCrumb.ascx" tagname="BreadCrumb" tagprefix="uc1" %>

    ...

<uc1:BreadCrumb ID="BreadCrumb1" runat="server" BreadCrumbTitleText="Current Page">
    <BreadCrumbItem Text="Home Page" NavigateURL="~/test/breadcrumbtest.aspx?iwentsomewhere=1" />
    <BreadCrumbItem Text="Secondary Page" NavigateURL="~/test/breadcrumbtest.aspx?iwentsomewhere=1" />
</uc1:BreadCrumb>

I think the issue lies with how the intellisense engine traverses supporting classes. All the working examples I see of this are not ascx, but Web Server Controls (cs, in a compiled assembly).

If anyone could shed some light on how to accomplish this with ascx controls, I'd appreciate it.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about intellisense