Lack of Intellisense when describing user control properties declaratively

So, I’ve been working on this project for several days now and couldn’t solve the problem of getting intellisense support for my custom internal properties for the user control (ascx, mind you).

I have seen a solution to this (using server controls, .cs mind you) many times. This article is well written. Everything works for me when using ascx controls except intellisense.

Here is the diagram 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 (which works fine, just not intellisense in 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>

, , intellisense . , , - ascx, - (cs, ).

- , ascx, .

+3
1

, , . ascx . , intelisense . , , , .

0

Source: https://habr.com/ru/post/1746634/


All Articles