Properties: Catch 22

  • Thread starter Thread starter pbd22
  • Start date Start date
P

pbd22

Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property



I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.


And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property

Public WriteOnly Property Subtitle() As String
Set(ByVal value As String)
_subTitle = Value
End Set
End Property



I get:

Quote:
Error 22 'Public ReadOnly Property Subtitle() As String' and 'Public
WriteOnly Property Subtitle() As String' cannot overload each other
because they differ only by 'ReadOnly' or 'WriteOnly'.


help?
 
pbd22 wrote:
When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.
<snip>

The implementing method doesn't need to be named after the implemented
one. Therefore, you can have:
Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

Private ReadOnly Property IWebPart_SubTitle As String _
Implements System.Web.UI.WebControls._
WebParts.IWebPart.SubTitle
Return Subtitle
End Property


HTH.

Regards,

Branco
 
Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.

And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property

Public WriteOnly Property Subtitle() As String
Set(ByVal value As String)
_subTitle = Value
End Set
End Property

I get:

Quote:
Error 22 'Public ReadOnly Property Subtitle() As String' and 'Public
WriteOnly Property Subtitle() As String' cannot overload each other
because they differ only by 'ReadOnly' or 'WriteOnly'.

help?

Hi

Just for your future reference, the error message you were getting
tells you all you need to know - i.e.
The first part ("Error 21 Class 'WebPartBase' must implement 'ReadOnly
Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. "

is telling you that you need to implement the ReadOnly Property
SubTitle().

The second part ("Implementing property must have matching 'ReadOnly'
or 'WriteOnly' specifiers.") is a more generic message telling you
that you have a mismatched property so you need to match it.

Hope that helps
Martin
 
Hi. I am caught between 2 errors.

When I have:

Public Property Subtitle() As String
Get
Return _subTitle
End Get
Set(ByVal value As String)
_subTitle = value
End Set
End Property

I get:

Error 21 Class 'WebPartBase' must implement 'ReadOnly Property
Subtitle() As String' for interface
'System.Web.UI.WebControls.WebParts.IWebPart'. Implementing property
must have matching 'ReadOnly' or 'WriteOnly' specifiers.

And, when I have:

Public ReadOnly Property Subtitle() As String
Get
Return _subTitle
End Get
End Property


The Subtitle property on the IWebPart interface is just a read only
property. Just get rid of the WriteOnly property, you don't need
it.

Chris
 
The Subtitle property on the IWebPart interface is just a read only
property. Just get rid of the WriteOnly property, you don't need
it.

Chris


Thanks all, much appreciated.
 
Back
Top