以声明方式描述自定义控件属性时缺少 Intellisense [英] Missing Intellisense While Describing Custom Control Properties Declaratively

查看:13
本文介绍了以声明方式描述自定义控件属性时缺少 Intellisense的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我已经在这个项目上工作了几天,但无法解决为我为用户控件自定义定义的内部属性(ascx,请注意)获得智能感知支持的问题.

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

我已经多次看到解决方案(使用服务器控件,请注意 .cs).此文章 很好.使用除智能感知之外的 ascx 控件时,一切都对我有用.

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.

这是我的代码大纲:

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

我认为问题在于智能感知引擎如何遍历支持类.我看到的所有工作示例都不是 ascx,而是 Web 服务器控件(cs,在已编译的程序集中).

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

如果有人能阐明如何使用 ascx 控件完成此任务,我将不胜感激.

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

推荐答案

我之前已经解决了这个问题,方法是从页面中删除所有用户控件和指令,然后将标记切换到设计视图.然后将 ascx 文件从解决方案资源管理器拖到设计窗口.如果您切换回标记视图,智能感知会突然获取所有属性.我确信有更好的方法,但我从来没有找到一种有效的方法.

I have solved this before by removing all the user controls and directives from the page and then switching the markup to design view. You then drag the ascx file from the solution explorer to the design window. If you swich back to markup view suddenly intelisense picks up all the properties. I am sure there is a better way but i have never found one that works.

这篇关于以声明方式描述自定义控件属性时缺少 Intellisense的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆