How can I expose a public property of a server control in the Properties window?
-
21-06-2021 - |
سؤال
I have an ASP.NET server control with some public properties.
If I drop the server control onto a form, I can access those properties from the code-behind. But I'd like to set them in the Properties window of the form designer.
The properties are just strings and booleans, not complex types. I'm using Visual Studio 2010 and .NET 4.0.
How can I expose server control properties to the Properties window in Design mode?
المحلول
Here's an oldie but a goodie. Looks like what you're looking for. Adding Design-Time Support to ASP.NET Controls
Here's a more recent article: Design-Time Attributes for Components
نصائح أخرى
Use the Browsable attribute decorator
//C#
[Browsable(true)]
public string MyProperty {
get {
}
set {
}
}
'VB
<Browsable(True)> _
Public Property MyProperty() As String
Get
End Get
Set
End Set
End Property
لا تنتمي إلى StackOverflow