473,785 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Renaming Public Properties of Inherited Class

Is there a way to rename the public properties of a inherited class? I am
inheriting an asp.net control (class) and am adding addtional functionality.
(in this case, up to 3 borders on an imagebutton control) I would like to
change the name of the BorderColor property to InnerBorderColo r because it
would make more sense in the context of this this new control.

Thanks

Earl
Nov 16 '05 #1
5 4641
Hello!

There is no way (AFAIK) to hide inherited members from a superclass. This
defeats the idea of object oriented programming, where you extent classes by
inheriting them and add more members, change the behaviour of inherited
members and so on.

I suggest adding the InnerBorderColo r property to your control and take it
from there. The superclass imagebutton control works they way it does, and
you change your own implementation according to your desired functionality.

Basically, think of your new control as an extended imagebutton control,
allowing the developers to do more than what is allowed with the general
imagebutton superclass. If they want to use that interface, they just resort
to casting.

The developers can freely choose which interface (and implementation) to
work with.

Not sure this is what you were looking for though, but I gave it a shot :-)

--
venlig hilsen / with regards
anders borum
--
Nov 16 '05 #2
You can create a new method in the inherited class that delegates to the
BorderColor property, but you cannot hide the BorderColor property itself.

I've generally found that if you start asking questions like that, then it
probably means you should be containing the class rather than inheriting it.

--
John Wood
EMail: first name, dot, last name, at priorganize.com

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:OE******** ******@TK2MSFTN GP11.phx.gbl...
Is there a way to rename the public properties of a inherited class? I am
inheriting an asp.net control (class) and am adding addtional functionality. (in this case, up to 3 borders on an imagebutton control) I would like to
change the name of the BorderColor property to InnerBorderColo r because it
would make more sense in the context of this this new control.

Thanks

Earl

Nov 16 '05 #3
After I posted this, I tried something to achive what I wanted. It seems to
work. Please advise if you see any problems with this approach. I am
assuming that this is NOT the classic use of OO and inheritance..bu t is
there any real problem with this approach?

(and BTW, I am not an idealist... I am far more interested it just getting
the job done as simply as possible)

Earl

In the properties below, the private properties hide the inherited
properties from public access. Then I create my new properties and set the
base properties from them...
//Hide Public Property BorderColor
private System.Drawing. Color BorderColor
{
get{
return System.Drawing. Color.Black;
}
}

//Hide Public Property BorderWidth
private System.Web.UI.W ebControls.Unit BorderWidth
{
get
{
return System.Web.UI.W ebControls.Unit .Pixel(0);
}
}
[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Drawing. Color InnerBorderColo r
{
get
{
return base.BorderColo r;
}
set
{
base.BorderColo r=value;
}
}

[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Web.UI.W ebControls.Unit InnerBorderWidt h
{
get
{
return base.BorderWidt h;
}
set
{
base.BorderWidt h=value;
}
}

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:OE******** ******@TK2MSFTN GP11.phx.gbl...
Is there a way to rename the public properties of a inherited class? I am
inheriting an asp.net control (class) and am adding addtional functionality. (in this case, up to 3 borders on an imagebutton control) I would like to
change the name of the BorderColor property to InnerBorderColo r because it
would make more sense in the context of this this new control.

Thanks

Earl

Nov 16 '05 #4
The public property should still be available, even though you declare a
private property with the same name in the inherited class.

If I have the following code:

public class A
{
public string plop
{
get
{
return "";
}
}
}

public class B : A
{
private string plop
{
get
{
return "";
}
}
}

When I instantiate B, I can still access A's plop.

It's possible the designer hides it in the properties though, even though
this would be a bug IMO.

--
John Wood
EMail: first name, dot, last name, at priorganize.com

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:un******** ******@tk2msftn gp13.phx.gbl...
After I posted this, I tried something to achive what I wanted. It seems to work. Please advise if you see any problems with this approach. I am
assuming that this is NOT the classic use of OO and inheritance..bu t is
there any real problem with this approach?

(and BTW, I am not an idealist... I am far more interested it just getting
the job done as simply as possible)

Earl

In the properties below, the private properties hide the inherited
properties from public access. Then I create my new properties and set the
base properties from them...
//Hide Public Property BorderColor
private System.Drawing. Color BorderColor
{
get{
return System.Drawing. Color.Black;
}
}

//Hide Public Property BorderWidth
private System.Web.UI.W ebControls.Unit BorderWidth
{
get
{
return System.Web.UI.W ebControls.Unit .Pixel(0);
}
}
[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Drawing. Color InnerBorderColo r
{
get
{
return base.BorderColo r;
}
set
{
base.BorderColo r=value;
}
}

[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Web.UI.W ebControls.Unit InnerBorderWidt h
{
get
{
return base.BorderWidt h;
}
set
{
base.BorderWidt h=value;
}
}

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:OE******** ******@TK2MSFTN GP11.phx.gbl...
Is there a way to rename the public properties of a inherited class? I am inheriting an asp.net control (class) and am adding addtional

functionality.
(in this case, up to 3 borders on an imagebutton control) I would like to change the name of the BorderColor property to InnerBorderColo r because it would make more sense in the context of this this new control.

Thanks

Earl


Nov 16 '05 #5
Very Interesting. From the designer page, the BorderColor property is
hidden, but from the code behind class, it is exposed and works. Rather odd
behavior but it answers my questions. Thanks for your help!

Earl

"John Wood" <j@ro.com> wrote in message
news:OY******** ******@tk2msftn gp13.phx.gbl...
The public property should still be available, even though you declare a
private property with the same name in the inherited class.

If I have the following code:

public class A
{
public string plop
{
get
{
return "";
}
}
}

public class B : A
{
private string plop
{
get
{
return "";
}
}
}

When I instantiate B, I can still access A's plop.

It's possible the designer hides it in the properties though, even though
this would be a bug IMO.

--
John Wood
EMail: first name, dot, last name, at priorganize.com

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:un******** ******@tk2msftn gp13.phx.gbl...
After I posted this, I tried something to achive what I wanted. It seems to
work. Please advise if you see any problems with this approach. I am
assuming that this is NOT the classic use of OO and inheritance..bu t is
there any real problem with this approach?

(and BTW, I am not an idealist... I am far more interested it just getting
the job done as simply as possible)

Earl

In the properties below, the private properties hide the inherited
properties from public access. Then I create my new properties and set the base properties from them...
//Hide Public Property BorderColor
private System.Drawing. Color BorderColor
{
get{
return System.Drawing. Color.Black;
}
}

//Hide Public Property BorderWidth
private System.Web.UI.W ebControls.Unit BorderWidth
{
get
{
return System.Web.UI.W ebControls.Unit .Pixel(0);
}
}
[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Drawing. Color InnerBorderColo r
{
get
{
return base.BorderColo r;
}
set
{
base.BorderColo r=value;
}
}

[Bindable(true),
Category("Apper ance"),
DefaultValue("" )]
public System.Web.UI.W ebControls.Unit InnerBorderWidt h
{
get
{
return base.BorderWidt h;
}
set
{
base.BorderWidt h=value;
}
}

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:OE******** ******@TK2MSFTN GP11.phx.gbl...
Is there a way to rename the public properties of a inherited class? I

am inheriting an asp.net control (class) and am adding addtional

functionality.
(in this case, up to 3 borders on an imagebutton control) I would like to change the name of the BorderColor property to InnerBorderColo r
because it would make more sense in the context of this this new control.

Thanks

Earl



Nov 16 '05 #6

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

Similar topics

9
4996
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class pointer which points to an instance of a derived class, but when I pass that base class pointer into a function, it can't access the derived object's public functions. Although, the base class pointer does call the appropriate virtual function...
1
1692
by: Siemel Naran | last post by:
Do using declarations respect private, protected, public access levels? class A { public: void f(); private: void f(int); }; class B : public A {
45
2423
by: Brett | last post by:
If I do this without declaring a corresponding field, is it considered bad design? What are the advantages or disadvantages to either method? Notice there is not set. public string URL { get { return "www.somewhere.com/test.aspx"; }
3
4485
by: M Shafaat | last post by:
Hi! I want to make a base class with some base properties and then derive different other classes from that in which I want to override the base properties to get specialized behaviour unique for each derived class as follows: MyBaseClass {PropertyA…} MyDerivedClassA: MyBaseClass {PropertyA //with unique, extended functionality, different from that of other classes) MyDerivedClassB: MyBaseClass {PropertyA //with unique, extended
5
1471
by: D Witherspoon | last post by:
What is happening is that I have a class (ClassA) that inherits a class (ClassB) which inherits System.Net.Mail.MailMessage Project 1 references Project 2, Project 2 references Project 3. When I declare an instance of "ClassA" in a thrid project I get all of the public methods/properties that are in the System.Net.Mail.MailMessage class, but I do not get any of the public methods or properties that are specirfically declared in Class B
12
10133
by: Robert W. | last post by:
This question concerns something I'm trying to do with the CF but it's really a generic C# question. With the Compact Framework, one can't add a radio button with a long label because the labels don't wrap. So I've decided to create my own custom radio button. With my version there will be a basic radio button with no text and its size reduced to 12 x 12. Then beside this I will place a LinkLabel, which will wrap, to give the...
10
2586
by: Smokey Grindle | last post by:
i want to inherit the list view class, but in the inherited class, hide the Header style property and the view property (basically its a detailed list with always clickable headers) how do I keep the base class properties from showing up in the inherited class when people change its properties in the IDE? thanks!
2
3036
by: Johnny Jörgensen | last post by:
Is there any way of renaming the properties of standard controls. I want to create a TextBox control inherited from a normal textbox control, but I want to use the property for something else. Let's say the program sets the Text property to "Mickey", then I want the TextBox to Show "Donald"? And if the user enters "Donald" into the textbox and I query the TextBox's text property, I want to read "Mickey"
6
9161
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %> On the Master Page I have a public property exposed: Public Property ErrorMessage() As String Get Return txtError.InnerText End Get
0
9645
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10155
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8979
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5383
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4054
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
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.