I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".
}
And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get
as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.
Does anybody know why? How can I display the category correctly only with set?
<Bindable(True)> _
<Category("First Payment Entry Properties")> _
<DefaultValue("")> _
<Localizable(True)> Property CssStyle_Text() As String
Get
Dim _CssStyle_Text As String = CStr(ViewState("CssStyle_Text"))
If _CssStyle_Text Is Nothing Then
Return String.Empty
Else
Return _CssStyle_Text
End If
End Get
Set(ByVal Value As String)
ViewState("CssStyle_Text") = Value
End Set
End Property
The question was, why the behaviour of a User Control's property displaying in a certain category in the Visual Studio property tab is different depending on the usage of get and set accessors. It may be simply a bug of Visual Studio?
You have to tell the property, what the category is, or else it will default it to misc.
It can't read your mind, and you didn't show any code for anyone to reference.
I posted code that showed you the answer. I should of made the line in bold. text.
<Category("Styles")> _
You have to get and set, if you don't get, then the properties explorer won't be able to display all the properties when in design view.
steschu
Member
45 Points
61 Posts
Category attribute of user control property does not work correctly in categories tab.
Aug 19, 2010 09:31 AM|LINK
Hi,
I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".
And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.
Does anybody know why? How can I display the category correctly only with set?
Thanks, S.
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: Category attribute of user control property does not work correctly in categories tab.
Aug 24, 2010 02:23 AM|LINK
Hi steschu,
Please refer this article about creating user control with read-only and write-only property:
http://articles.sitepoint.com/article/constructing-asp-net-web-pages/6
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
jkirkerx
Contributor
3750 Points
873 Posts
Re: Category attribute of user control property does not work correctly in categories tab.
Aug 25, 2010 03:52 AM|LINK
To use the property
.CssClass = [CssStyle_Text]
<Bindable(True)> _ <Category("First Payment Entry Properties")> _ <DefaultValue("")> _ <Localizable(True)> Property CssStyle_Text() As String Get Dim _CssStyle_Text As String = CStr(ViewState("CssStyle_Text")) If _CssStyle_Text Is Nothing Then Return String.Empty Else Return _CssStyle_Text End If End Get Set(ByVal Value As String) ViewState("CssStyle_Text") = Value End Set End Propertysteschu
Member
45 Points
61 Posts
Re: Category attribute of user control property does not work correctly in categories tab.
Jan 20, 2012 10:37 AM|LINK
Sorry, both replies didn't anser my question.
The question was, why the behaviour of a User Control's property displaying in a certain category in the Visual Studio property tab is different depending on the usage of get and set accessors. It may be simply a bug of Visual Studio?
jkirkerx
Contributor
3750 Points
873 Posts
Re: Category attribute of user control property does not work correctly in categories tab.
Apr 22, 2012 06:08 AM|LINK
You have to tell the property, what the category is, or else it will default it to misc. It can't read your mind, and you didn't show any code for anyone to reference. I posted code that showed you the answer. I should of made the line in bold. text. <Category("Styles")> _ You have to get and set, if you don't get, then the properties explorer won't be able to display all the properties when in design view.