Custom User Control and Friendly Property Item Collection (Like ListBox and ListItems, but with Listlt;Classgt;) on .ASPX(.ASPX 上的自定义用户控件和友好的属性项集合(类似于 ListBox 和 ListItems,但带有 ListClass))
问题描述
我一直想知道如何为用户控件创建一个公共属性,该属性类似于 .NET 原生项的集合属性(例如,ListBox 和 ListItems):
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 ListItems):
<asp:ListBox blablabla>
<asp:ListItem></asp:ListItem> <- Inline item collection...
</asp:ListBox>
我一直在网上查,但没有任何成功.我认为它必须是我需要添加到属性中的任何类型的属性,或者应该需要由用户控件继承的接口,但没有任何线索,并且已经考虑了很长时间.
I have been checking around the web but without any sucess. I think it must be any type of attribute that i need to add to the property, OR interface that should need to be inherited by the user control, but no clue about it, and have been thinking about it long time.
我必须在自定义用户控件上使用它,但 Visual Studio 没有将它识别为有效的项目集合.
I have got to work it on a custom user control, but Visual Studio didn't recognised it as a valid item collection.
假设我们有这个 userControl:
Let's say that we have this userControl:
public partial class userControls_Blablabla : System.Web.UI.UserControl
{
public List<configItem> ConfigItem {get; set; }
blablabla...rest logic here...
}
public class configItem {
public string Name {get; set;}
public string Url {get; set;}
public string Color {get; set;}
blablabla...rest logic here...
}
应该怎么做,才能在Visual Studio的.ASPX编辑器上做类似的事情,并被Intellisense识别?
How should be done, to be able to do something like that on the .ASPX editor of Visual Studio, and it get recognised by Intellisense?
<User_Control:userControls_Blablabla ID="blablabla" ...blablabla....>
<ConfigItem Name="1" Url="...." Color="..." />
<ConfigItem Name="2" Url="...." Color="..." />
<ConfigItem Name="3" Url="...." Color="..." />
</User_Control:userControls_Blablabla>
对不起我的英语,我知道它不是很好.
Sorry for my english, i know it's not very good.
提前致谢!
推荐答案
你需要用足够的信息来装饰控件和它的属性,以便设计人员在设计时可以了解细节.你检查过这个链接了吗?
You need to decorate the control and it's properties with sufficient information that the designer can pick up on details at design time. Have you checked this link?
这篇关于.ASPX 上的自定义用户控件和友好的属性项集合(类似于 ListBox 和 ListItems,但带有 List<Class>)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:.ASPX 上的自定义用户控件和友好的属性项集合(类似于 ListBox 和 ListItems,但带有 List<Class>)


- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01