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>)
基础教程推荐
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- rabbitmq 的 REST API 2022-01-01