473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Property and Control

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

Feb 28 '07 #1
1 1347
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/communities...1-3ab5b5eb90be

Hope it's clear now

Regards
--
Milosz
"shapper" wrote:
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

Feb 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Job Lot | last post by:
I have added a ProgressBar control to StatusBar control and created a custom property as below, to show the properties of the ProgressBar in Property Window of StatusBar. <Browsable(True)> _...
1
by: Georg Scholz | last post by:
Hello, The class "Control" contains a documented Property "ControlType". So for example, in a form, you can write code like this: Dim c as control set c = me.Controls("textbox1") if...
6
by: Tom Kiefer | last post by:
Question: If I have an ASP.NET User Control which defines/exposes a property that the page can use to specify a mode or data subset for the control to use, is there a way to tell the @OutputCache...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
3
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
2
by: Benton | last post by:
Hi there, I'm creating a custom server control, inheriting from TextBox. It has this AsDateTime property that returns the textbox contents converted to the nullable DateTime data type, as...
3
by: R.A.F. | last post by:
Hi, I have a custom control in which i have a property based on CollectionBase class. like the following one : //------- XGrid.cs file --------------// public ColumnsCollection Columns {
10
by: Derek Hart | last post by:
I can set focus to my property grid by using propgrid.Focus - but how can I set the default property that is always first? Or just set focus to the default property? Can this be done?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.