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

including several pages in one aspx page

P: n/a
hello all.

i'm used to scripting in php. there, you just include(bla.php) and it
works. so i have a template that defines my layout and stays the same
forever, but in that file, there's a table that's filled in with other
pages, header.php, footer.php, menubar.php,

i was trying to do the same with .net, but every page i try to include has
his own page directive (well, i need the code behind... so i can't just
delete those page directives), so .net wont allow it.

is there another way to do this? i read about master pages, but that's not
until .net v2...

tnx in advance,

roger

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tim
Hello,
Is this something you could solve with UserControls?

Many developer's successfully abstract Headers, Footers, and Menus to their
own user controls. You can then drag many UserControls onto a single ASPX
page.

Tim
http://timstall.dotnetdevelopersjournal.com/

"roger janssens via DotNetMonster.com" wrote:
hello all.

i'm used to scripting in php. there, you just include(bla.php) and it
works. so i have a template that defines my layout and stays the same
forever, but in that file, there's a table that's filled in with other
pages, header.php, footer.php, menubar.php,

i was trying to do the same with .net, but every page i try to include has
his own page directive (well, i need the code behind... so i can't just
delete those page directives), so .net wont allow it.

is there another way to do this? i read about master pages, but that's not
until .net v2...

tnx in advance,

roger

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2

P: n/a
Roger,

Actually, you don't have to wait for ASP.NET 2! Create yourself an .ASPX
page that will be the basis for the rest of your pages. In fact, call it
"BasePage.aspx". (Make this change in the "add new web form page" dialog
box because it'll make my message here shorter!) Add your style sheet,
header, footer, menubar, etc - and as Tim suggested, make your
header/footer/menubar into user controls.

Then when you create a new page, hop to the code-behind. (Click the "all
files" icon in your solution explorer, or right-click the .aspx file in the
solution explorer and choose "view code" to find the .aspx.cs file) Look
for this line:

public class TheNewBlankPageYouAdded : System.Web.UI.Page

Change it to:

public class TheNewBlankPageYouAdded : BasePage

What you're doing is changing the inheritance of the new web form. Instead
of inheriting directly from System.Web.UI.Page, as all Web Forms do, you're
inheriting from your new BasePage class. Since BasePage inherited from
System.Web.UI.Page, you're basically getting a web form with all of
BasePage's changes.

Note you may need to save TheNewBlankPageYouAdded.aspx , close it (from
VS.NET IDE), and re-open it to see the changes take effect in your design
environment.

So the old way you did things was to create your template page, and
cut/paste that template code into every PHP page, correct? Well, this new
way is based on the same thing; creating a template page- but instead of
cutting/pasting that code into every file, you just change the inheritance.

Tip: If your user controls (header, footer, menu) have text that changes;
set their properties up in the TheNewBlankPageYouAdded.Page_Load event.

It's a big adjustment curve going from a straight "scripting" language (and
all the inherent tricks you need to do) to a powerful "object orientated"
language, but it's well worth it!! Classic ASP was a straight-up scripting
language, just like PHP is- if you could do classic ASP, you could do PHP.
Think of ASP.NET as Java (object orientated) and you'll be fine.

Oh, my example assumes the C#.NET lanugage, but it should be very similar
with VB.NET.

-Thomas H

"roger janssens via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in
message news:b6******************************@DotNetMonste r.com...
hello all.

i'm used to scripting in php. there, you just include(bla.php) and it
works. so i have a template that defines my layout and stays the same
forever, but in that file, there's a table that's filled in with other
pages, header.php, footer.php, menubar.php,

i was trying to do the same with .net, but every page i try to include has
his own page directive (well, i need the code behind... so i can't just
delete those page directives), so .net wont allow it.

is there another way to do this? i read about master pages, but that's not
until .net v2...

tnx in advance,

roger

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #3

P: n/a
you wouldn't happen to have a link to some tutorial for that, would you?

either way, thanks for the hint. i'll google a bit myself too.

more advices welcome!

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #4

P: n/a
Tim
Hello,
UserControls are pretty common. Here's a quick tutorial:
http://samples.gotdotnet.com/quickst...bpagelets.aspx

Tim
http://timstall.dotnetdevelopersjournal.com/

"roger janssens via DotNetMonster.com" wrote:
you wouldn't happen to have a link to some tutorial for that, would you?

either way, thanks for the hint. i'll google a bit myself too.

more advices welcome!

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.