Reputation: 218962
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) ?
Upvotes: 0
Views: 4914
Reputation: 920
just add it as public property, then it should be useable for your needs.
Upvotes: 1
Reputation: 1082
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; }
}
Upvotes: 1
Reputation: 789
Assuming ASP.NET 3.5+ just create properties
public string YourProperty {get; set;}
Would be declarative on the control
Upvotes: 4