Properties not visible in property browser

O

Oskar Lundgren

I have been trying for hours to get this thing working, but since I'm
new to asp.net the solution may be simple. This is my problem:

I have created a class that represents a custom web control which
looks like this:

Namespace WebControls

Public Class TextField
Inherits System.Web.UI.WebControls.TextBox

Public Property FieldName() As String
Get
Return FieldName
End Get
Set(ByVal Value As String)
FieldName = Value
End Set
End Property

End Class

End Namespace

I successfully build my solution, add the web control to the toolbox
and add an instance of it to a web form. But, when I select this
instance, the property FieldName (declared above) does not show up in
the property browser. Why? All properties of the TextBox class show.
 
A

Alessandro Zifiglio

I'm sure all properties have browsable set to true by default however supply
this value and see if this makes any difference. Shouldnt. What i think the
real problem is that your not supply a local variable to your property :

private _FieldName as string

<Browsable(True)> _
Public Property FieldName() As String
Get
Return _FieldName
End Get
Set(ByVal Value As String)
_FieldName = Value
End Set
End Property
 
A

Alessandro Zifiglio

If its not clear to you why I've suggest you declare a local variable is
because properties do not allocate any storage on their own. To protect
their values from direct modification, variables used to store property
values should be declared as private, even if I dont see the connection with
this and why your property does not showup in the property grid. It should
be showing ;P
 
O

Oskar Lundgren

Thank you for your replies. It seems that my problem was of another
kind... As I am new to Visual Studio, I used "Build Solution" instead
of "Rebuild Solution", and this caused all my problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top