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

How is this done in ASP.Net

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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
3 1244
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 :)

"Rob Venable" <rv******@rogers.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

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

Similar topics

11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
17
by: blackswift | last post by:
code is from Warsaw university's CEPC code . They are world champion in the ICPC finals. #include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define FOR(i,a,b)...
12
by: Ark | last post by:
Hello NG, I arrange data in structs like { members... uint16_t crc; more members, maybe... } Then I need to save them, up to and including crc, in non-volatile memory or a file, as the case...
3
dfound
by: dfound | last post by:
#include<windows.h> #include<dos.h> #include<dir.h> #include<fstream.h> #include<stdio.h> #include<process.h> #include"resource.h" //resource header file
2
by: poolboi | last post by:
hey guys, i've done most of my web app. for searching almost done but then i got a small little problem with logging in i need to know how session tracking is done in perl if not my log in page...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.