Property and Control

S

shapper

Hello,

I am creating a user control where an Asp.Net control is used. It can
be either a button, an image button or a label.

I am trying to "expose" the Asp.Net control properties and events in
the page where the user control is used.

For that I defined a property as follows:

Private _Control As Control
Public Property Control() As Control
Get
Return _Control
End Get
Set(ByVal value As Control)
_Control = value
End Set
End Property ' Control

The problem is that the type of control that the User Control will
create and use depends of another User Control named property.

So, should I create 3 properties in my User Control of the 3 different
types: Button, ImageButton and Label?

Thanks,

Miguel
 
G

Guest

Miguel,

As i mentioned in one of my replies to earlier topic sent by you, if you
need to expose a property based on existing instance, and you just want to
change instance's properties not reference itself, apply readonly properties:

public readonly property MyButton() as Button
get
return me._myButton ' return existsing instance
end get
end property

If i added set property i would be possible to replace existing control with
another instance which we don't want to. Note we are interested in changing
internal button's properties, for instance:
myUserControl.MyButton.PropertyToSet = "newvalue"
not assigning to different button (it would be possible if I exposed set
property):
myUserControl.MyButton = new Button()

I have already replied to rest of the topic in your later post here:
http://www.microsoft.com/communitie...pnet&mid=a8fd471d-0fee-4ff2-9ea1-3ab5b5eb90be

Hope it's clear now

Regards
 

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,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top