override default values in a constructor

T

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
 
T

Teemu Keiski

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.
 
T

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?
 
C

Craig Deelsnyder

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?

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/chapter_4915_07.asp
 
T

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.
 

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,780
Messages
2,569,608
Members
45,249
Latest member
KattieCort

Latest Threads

Top