473,385 Members | 1,753 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,385 software developers and data experts.

override default values in a constructor

TJS
How can I override the default values, of a class constructor , from an
ASP.net page ?

Public Sub New( )
HeaderStyle.BackColor = ColorTranslator.FromHtml("#5C85AD")
HeaderStyle.ForeColor = Color.White
HeaderStyle.Font.Bold = True
End Sub
Nov 19 '05 #1
4 2889
If you can derive your own class from it then that way, so that create a new
default constructor (in the derived class) where base class constructor is
called, and set the new default values after that call.

Otherwise you are "at mercy" of the class's API (methods and properties) so
that can you access those properties via class's public interface and just
set them.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #2
TJS
It is my own class, but I don't know what is meant by "create a new default
constructor where base class constructor is
called", I thought there was only one?
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eN****************@tk2msftngp13.phx.gbl...
If you can derive your own class from it then that way, so that create a
new default constructor (in the derived class) where base class
constructor is called, and set the new default values after that call.

Otherwise you are "at mercy" of the class's API (methods and properties)
so that can you access those properties via class's public interface and
just set them.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

Nov 19 '05 #3
On Sun, 12 Jun 2005 12:13:10 -0500, TJS <no****@here.com> wrote:
It is my own class, but I don't know what is meant by "create a new
default
constructor where base class constructor is
called", I thought there was only one?
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eN****************@tk2msftngp13.phx.gbl...
If you can derive your own class from it then that way, so that create a
new default constructor (in the derived class) where base class
constructor is called, and set the new default values after that call.

Otherwise you are "at mercy" of the class's API (methods and properties)
so that can you access those properties via class's public interface and
just set them.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



Constructors are not inherited (and then not overridden) by derived
classes; all classes get an empty default constructor (New()) that does
nothing. If you wish to 'override' a constructor, you have to redefine it
in the derived class, and if you wish to still run the constructor logic
that was defined in the superclass, you must call it in the first line of
code of the constructor. I believe VB.NET uses MyBase:

http://www.vbip.com/books/1861004915...er_4915_07.asp

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #4
TJS
thanks for the link, it confirms that constructors can be overriden and that
I have to explicitly add "MyBase.new" to the constructor, but it never tells
me how to overrride the values in the constructor, or how to call the
constructor with the override values from an ASPX file.


"Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message
news:op***************@cowboy.hsd1.mn.comcast.net. ..
On Sun, 12 Jun 2005 12:13:10 -0500, TJS <no****@here.com> wrote:
It is my own class, but I don't know what is meant by "create a new
default
constructor where base class constructor is
called", I thought there was only one?
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:eN****************@tk2msftngp13.phx.gbl...
If you can derive your own class from it then that way, so that create a
new default constructor (in the derived class) where base class
constructor is called, and set the new default values after that call.

Otherwise you are "at mercy" of the class's API (methods and properties)
so that can you access those properties via class's public interface and
just set them.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



Constructors are not inherited (and then not overridden) by derived
classes; all classes get an empty default constructor (New()) that does
nothing. If you wish to 'override' a constructor, you have to redefine it
in the derived class, and if you wish to still run the constructor logic
that was defined in the superclass, you must call it in the first line of
code of the constructor. I believe VB.NET uses MyBase:

http://www.vbip.com/books/1861004915...er_4915_07.asp

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 19 '05 #5

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

Similar topics

1
by: Programmer | last post by:
Hi All Here is my problem I'm using a SQLDataAdapter and DataSet I use the method FillSchema(myDataset, SchemaType.Source) The problem is that when i Check the default Values of the Dataset...
15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
16
by: jonathan cano | last post by:
QUESTION: In practice, lines 36 and 37 below are usually equivalent to the default copy constructor (.e.g line 33). My questions are: (a) Does ISO 14882 guarantee that lines 36 and 37 are...
29
by: John Wood | last post by:
Even though CSC does its best to detect use of unassigned variables, it often misses it... for example if you just declare a double in a class without assigning a default value, it has a default...
10
by: Alan G Isaac | last post by:
My class MyClass reuses many default parameters with a small number of changes in each instance. For various reasons I decided to put all the parameters in a separate Params class, instances of...
3
by: Charlie | last post by:
Imagine I subclass Panel into MyPanel and set a few property values to my own defaults as shown below. Eg. I set BackColor to by LightYellow. When I add MyPanel to a form, it will write the...
10
by: Joel | last post by:
Is it true that if we don't specify a default constructor for our class, then the C# compiler provides us with its own that zeroes (or assigns default values) to the data members? I wrote a...
4
by: Jeevang | last post by:
Hi, We need copy constructor when we are passing the object to a function or if the function returns any object. Suppose if we haven't defined the user defined copy constructor, it will give a...
4
by: Dave Burns | last post by:
Hello, I am trying to specify a logical default value for a in a WCF Web Service using basicHttpBinding. I realize that the language defaults are: int - 0 string - null bool - false
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.