How is this done in ASP.Net

  • Thread starter Thread starter Rob Venable
  • Start date Start date
R

Rob Venable

Hi everybody,
I'm moving from ASP to ASP.net and I'm wondering how this can be done in
.Net. I have multiple pages on my website and I don't want to have
multiple Headers and footers on each webpage so that if I make a
change...I don't have to do it on multiple pages. In ASP, I just put my
PrintHeader and PrintFooter information in subroutines and that works
fine but in .Net it's a little different because I use the code behind
page and I'd have to declare all form variables for all of my pages in
the same subroutine. What I usually do is:

call PrintHeader()
call Main()
call PrintFooter()

but that doesn't work well in .Net.
Same if I use an include file.

Any suggestions?

Thanks
Rob
 
You can include usercontrols (.ascx) on your pages. This will give you the
same effects as with include files in classic ASP.

This is an exampel to be put in top of your page:
<%@ Register TagPrefix="SomeThing" TagName="MyHeader" Src="~/Header.ascx" %>
<%@ Register TagPrefix="SomeThing" TagName="MyFooter" Src="~/Footer.ascx" %>

To show the page simple write the tags where you want them on your page:
<SomeThing:MyHeader id="header" runat="server" />
--> Your content
<SomeThing:MyHeader id="footer" runat="server" />

tomledk :)
 
Thanks for the tip. Would I run into problems with the scope of my
variables if I use this .ascx file in all of my pages? With the include
files I would get "variables not declared" errors unless I declare all
form variables in the include file.

Thanks
Rob
 
Back
Top