ASP.net 自定义服务器控件中 CSS 类的设计时属性
希望一些自定义控件设计者/构建者可以帮助
我尝试构建我的第一个自定义控件,该控件对于客户详细信息收集表单至关重要。 该表单包含一系列需要应用各种样式的元素。 理想情况下,我希望 VS 2005/2008 属性界面能够像在控制级别一样应用 CSSClass,即具有可用 CSS 类的下拉列表。
以要应用于图例标签的类为例,
/// <summary>Css Class for Legend</summary>
[Category("Appearance")]
[Browsable(true)]
[DefaultValue("")]
//I am at a loss as to what goes in [Editor]
[Editor(System.Web.UI.CssStyleCollection), typeof(System.Drawing.Design.UITypeEditor))]
public string LegendCSSClass
{
get { return _LegendCSSClass; }
set { _LegendCSSClass = value; }
}
我尝试了几个选项,正如您从上面看到的那样,但运气不佳。
希望我缺少一些简单的东西。
我也很乐意提供有关的参考资料
[Editor]
attributeHopefully some Custom Control Designers/Builders can help
I'm attempting to build my first custom control that is essential a client detail collection form. There are to be a series of elements to this form that require various styles applied to them. Ideally I'd like the VS 2005/2008 properties interface to be able to apply the CSSClass as it does at the control level, i.e. with a dropdown list of available CSS Clases.
Take for example the Class to be applied to the legend tag
/// <summary>Css Class for Legend</summary>
[Category("Appearance")]
[Browsable(true)]
[DefaultValue("")]
//I am at a loss as to what goes in [Editor]
[Editor(System.Web.UI.CssStyleCollection), typeof(System.Drawing.Design.UITypeEditor))]
public string LegendCSSClass
{
get { return _LegendCSSClass; }
set { _LegendCSSClass = value; }
}
I have tried a couple of options, as you can see from above, without much luck.
Hopefully there is something simple I am missing.
I'd also be happy for references pertaining to the
[Editor]
attribute
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 CssClassProperty 属性添加到您的属性中。
来自 MSDN:添加级联样式表 ( CSS)在设计时编辑属性的功能。
顺便说一句,对于这类问题,Lutz Reflector 是你的朋友。 您可以查看应用于 .NET Framework 类中类似属性的属性。
Add the CssClassProperty attribute to your property.
From MSDN: Adds Cascading Style Sheet (CSS) editing capabilities to a property at design time.
BTW for this kind of question, Lutz Reflector is your friend. You can look at the attributes that are applied to similar properties in .NET Framework classes.