自定义用户控件和友好的酒店项目集合(类似于ListBox和ListItems的,​​但名单,LT;类>)上.ASPX [英] Custom User Control and Friendly Property Item Collection (Like ListBox and ListItems, but with List<Class>) on .ASPX

查看:180
本文介绍了自定义用户控件和友好的酒店项目集合(类似于ListBox和ListItems的,​​但名单,LT;类>)上.ASPX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想了很久如何为用户控件的工作就像.NET本地项目的集合属性(例如,ListBox和ListItems的)做一个公共属性:

 < ASP:列表框blablabla>
    < ASP:ListItem的>< / ASP:ListItem的> < - 内联项目集...
< / ASP:列表框>

我已经检查各地的网络,但没有任何sucess。我想那一定是任何类型的属性,我需要添加到属性,或者说,应该需要由用户控制继承接口,但没有关于它的线索,并一直在想这件事很久了。

我得工作,它在一个自定义用户控件,但Visual Studio中并没有认识到这是一个有效的项目集合。

让我们说,我们有这个用户控件:

 公共部分类userControls_Blablabla:System.Web.UI.UserControl
{
  公开名单< configItem> ConfigItem {搞定;组; }  blablabla ......在这里休息的逻辑...
}公共类configItem {
   公共字符串名称{;组;}
   公共字符串网址{搞定;组;}
   公共串色{搞定;组;}  blablabla ......在这里休息的逻辑...
}

应该怎么做,才能够做这样的事情在Visual Studio中的.ASPX编辑,并得到由智能感知识别?

 < User_Control:userControls_Blablabla ID =blablabla...... blablabla ......>
   < ConfigItem NAME =1URL =....颜色=.../>
   < ConfigItem NAME =2URL =....颜色=.../>
   < ConfigItem NAME =3URL =....颜色=.../>
< / User_Control:userControls_Blablabla>

对不起,我的英语,我知道这是不是很好。

在此先感谢!


解决方案

您需要装饰的控制,它是有足够的信息属性设计师可以在设计时的细节有起色。
你检查这链接 <? / p>

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.

I have got to work it on a custom user control, but Visual Studio didn't recognised it as a valid item collection.

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

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.

Thanks in advance!

解决方案

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?

这篇关于自定义用户控件和友好的酒店项目集合(类似于ListBox和ListItems的,​​但名单,LT;类&GT;)上.ASPX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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