[英]How to add custom property to asp.net custom server control?
我已经创建了一个asp.net自定义控件,现在想从将使用该控件的页面中向其传递一些值。有什么办法可以将自己的属性添加到该控件中(例如Label控件具有Text属性) )?
It's a class. 这是一堂课。 Add a public property to it.
向其添加公共属性。
Assuming ASP.NET 3.5+ just create properties 假设ASP.NET 3.5+仅创建属性
public string YourProperty {get;
公用字符串YourProperty {get; set;}
组;}
Would be declarative on the control 将在控件上声明
Adding a property to a custom control in asp.net is no different than adding a property on any class in C# (for instance). 在asp.net中向自定义控件添加属性与在C#中的任何类上添加属性没有什么不同(例如)。
public class Custom : Control
{
public string Text { get; set; }
}
只需将其添加为公共财产,即可满足您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.