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


基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01