开发者

How to add custom property to asp.net custom server control?

开发者 https://www.devze.com 2023-02-03 10:44 出处:网络
I have created an asp.net custom control and now want to pass some values to it from the page which will use the control.Is there any way i can add my own property to the control (like Text 开发者_开发

I have created an asp.net custom control and now want to pass some values to it from the page which will use the control.Is there any way i can add my own property to the control (like Text 开发者_开发百科property is present for a Label control) ?


It's a class. Add a public property to it.


Assuming ASP.NET 3.5+ just create properties

public string 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).

public class Custom : Control
{
    public string Text { get; set; }
}


just add it as public property, then it should be useable for your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消