|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
override default values in a constructorHow 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 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. 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? Show quoteHide quote "Teemu Keiski" <jot***@aspalliance.com> wrote in message news:eN%23kBlzbFHA.2756@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 > On Sun, 12 Jun 2005 12:13:10 -0500, TJS <nospam@here.com> wrote:
Show quoteHide quote > It is my own class, but I don't know what is meant by "create a new Constructors are not inherited (and then not overridden) by derived > default > constructor where base class constructor is > called", I thought there was only one? > > > "Teemu Keiski" <jot***@aspalliance.com> wrote in message > news:eN%23kBlzbFHA.2756@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 >> > > 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 -- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET 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. Show quoteHide quote "Craig Deelsnyder" <cdeelsny@no_spam_4_meyahoo.com> wrote in message news:op.sr9skcb675dg5d@cowboy.hsd1.mn.comcast.net... > On Sun, 12 Jun 2005 12:13:10 -0500, TJS <nospam@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" <jot***@aspalliance.com> wrote in message >> news:eN%23kBlzbFHA.2756@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/chapter_4915_07.asp > > -- > Craig Deelsnyder > Microsoft MVP - ASP/ASP.NET
Other interesting topics
an old geezer running visual studio for the first time
SqlParameters SqlDbType.Char in VB Question DataGrid Runtime DropDown - ViewState Issue question about the "Page Controller" pattern Evaluation Application How to get network user name with FORMS authentication Reading values from a Word document... Strange Datagrid Update Problem Global Variables!q interesting fact about date. |
|||||||||||||||||||||||