By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,306 Members | 1,621 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,306 IT Pros & Developers. It's quick & easy.

Best Methodology For Creating A Head For Web Page

P: n/a
Hi there,

I am developing a web site with a number of pages, I want each page to have
the same heading section which will include both the raw html and vb.net
code which handle rollovers for some images which will also be included.

My initial feeling on how to do this would be to create a base class web
page and then inherit it with all the HTML response.writing and image
rollover code already there. Problem being that my page already inherits the
System.Web.UI.Page class so I cant do it that way.

What is the recommended way of including the same basic code and html for
each page on a site? Web pages on sites nearly always have the same header
and menu information on each page, how should this be done in a nice proper
OO way?

Hope I haven't opened up a can of worms, I know its a general question with
lots of possible answers but it would be good to be pointed in the right
direction :)
Thanks
Steve

Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Most people just use an include statement and have the code in the \includes
directory.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:%7***************@newsfe2-gui.ntli.net...
Hi there,

I am developing a web site with a number of pages, I want each page to
have
the same heading section which will include both the raw html and vb.net
code which handle rollovers for some images which will also be included.

My initial feeling on how to do this would be to create a base class web
page and then inherit it with all the HTML response.writing and image
rollover code already there. Problem being that my page already inherits
the
System.Web.UI.Page class so I cant do it that way.

What is the recommended way of including the same basic code and html for
each page on a site? Web pages on sites nearly always have the same header
and menu information on each page, how should this be done in a nice
proper
OO way?

Hope I haven't opened up a can of worms, I know its a general question
with
lots of possible answers but it would be good to be pointed in the right
direction :)
Thanks
Steve

Nov 21 '05 #2

P: n/a

"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:%7***************@newsfe2-gui.ntli.net...
Hi there,

I am developing a web site with a number of pages, I want each page to
have
the same heading section which will include both the raw html and vb.net
code which handle rollovers for some images which will also be included.

My initial feeling on how to do this would be to create a base class web
page and then inherit it with all the HTML response.writing and image
rollover code already there. Problem being that my page already inherits
the
System.Web.UI.Page class so I cant do it that way.

Sure you can. Just create your own base Page class inheriting
System.Web.UI.Page, and inherit from that instead.
What is the recommended way of including the same basic code and html for
each page on a site? Web pages on sites nearly always have the same header
and menu information on each page, how should this be done in a nice
proper
OO way?


Page inheritence or Web user controls. See, eg

http://www.codeproject.com/aspnet/page_templates.asp

and

http://msdn.microsoft.com/library/de...ercontrols.asp

David
Nov 21 '05 #3

P: n/a

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Most people just use an include statement and have the code in the
\includes directory.


Include is the old ASP way, and it requires you to put code in your ASPX
files, which is a pain since you don't get intellisense and it doesn't
compile until the user hits it.

Yuck.

David
Nov 21 '05 #4

P: n/a
Stephen,
In addition to the other comments:

I normally use a UserControl, that I manually add to each page.

VS.NET 2005 (aka Whidbey, currently in beta, due out later in 2005) will
support Master Pages which will significantly simplify what you want to do.

For details on VS.NET 2005 see:
http://lab.msdn.microsoft.com/vs2005/

For details on Master Pages see:

http://msdn.microsoft.com/library/de...asterpages.asp

Hope this helps
Jay
"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:%7***************@newsfe2-gui.ntli.net...
Hi there,

I am developing a web site with a number of pages, I want each page to
have
the same heading section which will include both the raw html and vb.net
code which handle rollovers for some images which will also be included.

My initial feeling on how to do this would be to create a base class web
page and then inherit it with all the HTML response.writing and image
rollover code already there. Problem being that my page already inherits
the
System.Web.UI.Page class so I cant do it that way.

What is the recommended way of including the same basic code and html for
each page on a site? Web pages on sites nearly always have the same header
and menu information on each page, how should this be done in a nice
proper
OO way?

Hope I haven't opened up a can of worms, I know its a general question
with
lots of possible answers but it would be good to be pointed in the right
direction :)
Thanks
Steve

Nov 21 '05 #5

P: n/a
Thanks for all the tips guys, i've now created a base web page class which
extends System.Web.UI.Page which is great and everything... But, i've got
all my rollover code in the page_load sub of my base web page class. Now on
many pages i'm going to want to add other bits and bob's to the page_load
sub. How can I do this? You can extend a class but not a method (sub), I
suppose I could over-ride it but then i'd have to enter in all the base
class rollover code again which kinda defeats the object.

Thanks again
Nov 21 '05 #6

P: n/a
LOL, Oh well, never mind, there are other ways like creating your own page
class. Next year you wont have this issue with 2005 but I dont suppose
that's gonna help you right now.

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"David Browne" <davidbaxterbrowne no potted me**@hotmail.com> wrote in
message news:uq**************@TK2MSFTNGP12.phx.gbl...

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in
message news:%2****************@TK2MSFTNGP15.phx.gbl...
Most people just use an include statement and have the code in the
\includes directory.


Include is the old ASP way, and it requires you to put code in your ASPX
files, which is a pain since you don't get intellisense and it doesn't
compile until the user hits it.

Yuck.

David

Nov 21 '05 #7

P: n/a
Stephen,
Page_Load is an event, you can have multiple event handlers handle the
event. Which means you can have your base page handle it & your derived
pages also handle it.

What I normally do is override the Page.OnLoad method instead, being certain
to call MyBase.OnLoad and do any "event handling" in the OnLoad method.

Page.OnLoad raises the Load event.

I normally override the On<event> methods when I am handling an event
internally in a derived class. I normally handle the <event> when I am
handling an event externally, when the object is contained in another
object.

For details on the relationship between <event> and On<event> see:

The "Design Guidelines for Class Library Developers" has some information on
implementing events in both C# & VB.NET.

http://msdn.microsoft.com/library/de...Guidelines.asp

http://msdn.microsoft.com/library/de...Guidelines.asp

Note: within VB.NET you can simply use RaiseEvent rather then checking to
see if a delegate variable is Nothing and invoking the delegate variable...

Hope this helps
Jay
"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:Y3**************@newsfe2-gui.ntli.net...
Thanks for all the tips guys, i've now created a base web page class which
extends System.Web.UI.Page which is great and everything... But, i've got
all my rollover code in the page_load sub of my base web page class. Now
on
many pages i'm going to want to add other bits and bob's to the page_load
sub. How can I do this? You can extend a class but not a method (sub), I
suppose I could over-ride it but then i'd have to enter in all the base
class rollover code again which kinda defeats the object.

Thanks again

Nov 21 '05 #8

P: n/a
Stephen,

I never did what you ask, however in this I would probably for sure use a
shared class, which will function very well for problems like this in a
webapplication.

The shared class belongs to the application so will be loaded only with the
first page (session) that is used at that time and after can be used for all
pages for every session that is active.

I hope this gives an idea?

Cor
"Stephen Adam" <st**********@ntlworld.com>
Hi there,

I am developing a web site with a number of pages, I want each page to
have
the same heading section which will include both the raw html and vb.net
code which handle rollovers for some images which will also be included.

My initial feeling on how to do this would be to create a base class web
page and then inherit it with all the HTML response.writing and image
rollover code already there. Problem being that my page already inherits
the
System.Web.UI.Page class so I cant do it that way.

What is the recommended way of including the same basic code and html for
each page on a site? Web pages on sites nearly always have the same header
and menu information on each page, how should this be done in a nice
proper
OO way?

Hope I haven't opened up a can of worms, I know its a general question
with
lots of possible answers but it would be good to be pointed in the right
direction :)
Thanks
Steve

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.