简体   繁体   中英

Can i add optional values to my user control (creating intelisence of my own for me user controls)?

I need to add some UCs for my app and I want to enable to enter to my UC parameter only values that i choose, for that i need to give the programmer the values while he/she is adding the UC to the app and choosing to use the param.

Is there a way to create a live of optional values to pop when the programmer choose the param of the UC?

10x :-)

Don't know if this is what you mean exactly, but if you create a public property in the code-behind of your User Control, that property will show up in intellisense in the markup.

Similarly, if you use an Enum in the code behind, the valid options will pop up in intellisense when you type in the markup.

Here's an example:

// FooControl.ascx.cs
namespace WebApplication1
{
    public enum TypeEnum
    {
        Asynch = 0,
        Synch = 1,
        OneShot = 2
    }

    public partial class FooControl : System.Web.UI.UserControl
    {
        public TypeEnum Type { get; set; }
    }
}

And then in the markup:

<Foo:FooControl ID="Foo1" runat="server" Type="Asynch" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM