Master Pages - loading of ContentPlaceHolder

J

John H W

I currently use frames for a website. I plan on moving this site over to .NET
now that the ISP is using ver 2 beta 2. I currently have the website working
as below, but would like to get rid of the frame.

My question is: can I use a master page(s) to do what I need to do.

The page has the website's "banner" (name, logos, etc.) across the top, the
site's menu (navigation) on the left side and a menu of "temporary" but long
standing items (links) on the right. In the middle I want to have "news"
items (linked to an article) when the page first comes up (or comes back to),
but when you click on a menu page (currently pointing to a pdf, doc, html or
asp page), a news item, or a long standing item, that item will appear in the
middle - replacing the "news" items.

It would appear that I could use asp:panel, programmeticly putting in the
name of the page to load in the middle, but the books and other info I find
only mention ascx pages. I have never used ascx pages and can find little to
explain them.

Question: Can I point the panel to a type of page other than an ascx page?

How I thought of doing this is to use ?url="name of file" in recalling the
default.aspx file with the "news" as the default. (menu has homepage which
would reload default.aspx without the ?url. But I need to know is I have to
change all my html pages.

Thanks,
John H W
 
B

Brock Allen

Question: Can I point the panel to a type of page other than an ascx

Panels don't point to anything. They are a control that can contain other
controls. You can create any control and have it live "inside" the Panel
-- just create the other control and add it to the Panel's Controls collection.
If this doesn't get you going in the right direction, can you post a snippet
of your current code so we can discuss those specifics?
 
J

John H W

I don't have any code yet, I am still in the planning stage. I need to be
able to "load" into the center portion of the site various things which are
now in html, asp, or pdf. I am now looking to having these come up into
another window, but would rather then load into the center of the site.
 
G

G

Panels don't point to anything. They are a control that can contain other
What about Server Side Includes, or, Iframes?

G.
 
B

Brock Allen

Well, MasterPages will accomplish this. You setup a .master file with your
template, and somewhere in the .master where you want the individual page
to fill in the details you place a <asp:ContentPlaceHolder> control. Then
in the .aspx you indicate you want to use a .master (via <@% Page MasterPageFile="foo.master"%>)
and then you only have a <asp:Content> control that fills in the details
of what that page is to show. It's quite a nice feature/improvement in v2.0.
 
B

Brock Allen

What about Server Side Includes, or, Iframes?

Server side includes are supported, but the implementation is far less efficient
than using a user control. They exist for backwards compatibility but should
be used for new development.

I suppose an IFRAME would work, but that causes additional requests to the
server. A master page is served up in a single request.
 
J

John H W

Brock:

All the examples I have show that I have to have the contents of the
ContentPlaceHolders in one .aspx page (which calls the master page). Is
there a way to put the contents of different ContentPlaceHolders in different
..aspx pages? What I need to do is illustrated in sudocode:

In default.aspx:
<@% Page MasterPageFile="main.master"%>
<script>
Void Function Page_Load(object sender, EventArgs e)
If default.aspx is called with a parameter then
document.all.CenterFile.innerHTML = (load html formatted file named in
parameter)
else load the document.all.CenterFile.innerHTML from a default.html
file
End Function
</script>
....
<asp:Content runat="server" contentplaceholderID="CenterFile" />

Would something like this work?

Thanks,
John H W
 
B

Brock Allen

Umm, I'm not really following what you're trying to do. If they want different
"stuff" to go into the ContentPlaceHolder then why doesn't the user just
browse to a different ASPX page? Each ASPX page that uses the same master
will hiave its own content ("stuff") to show. I feel like I'm missing something,
so let me know what it is :)
 
J

John H W

When a user selects a linked item (from the menu on the left hand page, a
news store from the center section or the quick menu on the right side of the
page ), we want that item to appear in the center, replacing the "News" item
links that would be the default.

Here is the layout of the master page (open window until you have three
columns):

L O G O a n d N A M E

Menu Headline Quick Link
item Headline Quick Link
item Headline Quick Link

Copyright Info

We want any item selected under the menu, headline or quick link to display
where the headline had been.

The reason we don't want to have different .aspx pages calling the same
..master is that all of the menu and Quick links items would have be
duplicated on the .aspx content pages. What I would prefer to do is just
make a html formatted page (without having to put in the <html><body> tags,
just the formatting tags and the content, then load it dynamically into the
<asp:content> tag of the default.aspx page.

John H W
 
B

Brock Allen

The reason we don't want to have different .aspx pages calling the
same .master is that all of the menu and Quick links items would have
be duplicated on the .aspx content pages. What I would prefer to do
is just make a html formatted page (without having to put in the
<html><body> tags, just the formatting tags and the content, then load
it dynamically into the <asp:content> tag of the default.aspx page.

Umm, the point of the master is so that you don't have to replicate the common
layout or HTML across each of the pages. The master can also have common
code that reacts to poastbacks and other events. You don't have to have just
a single master page for the entire site. You can have some set of pages
use one master and then antoher set of pages user a different one. One other
thing is that Master pages can be nested, so a master can use another master,
but that requires some planning when developing your website.

If you don't think that master pages will do what you need, then you can
always factor out the common HTML into a UserControl (which is an ASCX file).
The ASCX file can either be included staticially on a page (or in a master)
or it can be loaded dynamically via LoadControl. From what you described
above, this might be the approach you want to take.

Sorry I couldn't give you more definitive help.
 
J

John H W

We are now back to one of my original questions - .ascx pages. I can find
very little info on .ascx pages, how they are set up, etc. Do you know of a
good source?

Thanks for your help.

John H W
 
J

John H W

Brock, thanks for all your help in pointing my thinking in the proper
direction.

John H W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top