473,564 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1364
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.M yButton.Propert yToSet = "newvalue"
not assigning to different button (it would be possible if I exposed set
property):
myUserControl.M yButton = 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
1564
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)> _ Public Property ProgressBar() As ProgressBar Get Return ProgressBar1 End Get Set(ByVal Value As ProgressBar)
1
2778
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 c.ControlType = acTextBox then ...
6
2734
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 directive to vary its cache based on that property value? I.e., I have: <my:control runat="server" id="mcOne" Flag="One" /> <my:control...
7
2977
by: Shimon Sim | last post by:
I have a custom composite control I have following property
0
5552
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 is used to view the state of the running jobs and schedule new jobs. The control also runs in the context of Internet Explorer (we do this so the...
3
6733
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 following default properties: Height = 32px, Width = 144px. I declare the Width property in my control as... \\\
2
4232
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 follows: public class TextBoxWeb : System.Web.UI.WebControls.TextBox {
3
4748
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
10008
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
7665
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.