如何向自定义控件添加属性 [英] How to add Properties to Custom Controls
本文介绍了如何向自定义控件添加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我想为TextBox创建自定义服务器控件
,因为我想将textBox长度设置为5或10时
用户类型MaxLength属性然后值应为只有5或10个设置
for ex
< cc1:TextBox runat =serverMaxLength =5>
5或10应该在选项中可见
plz help
Hi i want to create Custom Server Controls for TextBox
in that i want to set textBox length as 5 or 10 when
user Type MaxLength attribute then value should be only 5 or 10 to set
for ex
<cc1:TextBox runat="server" MaxLength="5">
5 or 10 should be visible in option
plz help
推荐答案
ASP.NET中的控件属性为no与任何其他属性不同: http://msdn.microsoft.com/en-us/library/65zdfbdt。 aspx [ ^ ]。
-SA
Control's properties in ASP.NET are no different from any other properties: http://msdn.microsoft.com/en-us/library/65zdfbdt.aspx[^].
—SA
推荐
创建自定义控件和属性 [ ^ ]
自定义属性的自定义控件 [ ^ ]
最后一个问题,
Refer
Create Custom Control and Properties[^]
Custom Control with Custom Properties[^]
And for the last qusetion ,
Quote:
5或10应该在选项中可见
5 or 10 should be visible in option
您可以使用枚举来使用预定义值,这些值将出现在标记上以供选择。
参考
http://stackoverflow.com/questions/1604287/create-property-in-asp-net-control-to-c-sharp-and-aspx [ ^ ]
这篇关于如何向自定义控件添加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文