Different head content for content pages using one Master page

Hello,

I have just started using ASP.NET. I am transferring a site from php to asp.  I have one master page as the default content which has a title and meta content.  However, I want to have different title and meta content for each content page.  This is probably a really dumb question, but i have just started!Stick out tongue

 Cheers

Andrew Welch

Abtec Network Systems


Current project: Cycle round the world
0
ajw
8/29/2006 4:21:48 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

6 Replies
1621 Views

Similar Articles

[PageSpeed] 53
Get it on Google Play
Get it on Apple App Store

Hello ajw

I am pritty new to asp.net myself but I have been working with a master page and content pages on my latest e-commerce website and from my understanding is that anything put on your master page will reflect on the content pages connected to that masterpage...Here is a possible solution.

Since the code from the master page is translated throughout the rest of the content pages automaticlly.... I am sure you could include all of your meta content in the head tag of your masterpage and it will reflect throughout the rest of your pages.....as for the title well You might be able to leave the title out of your master page and in the content pages that are linked to your masterpage put them in there........that will give you the flexibility to have seperate titles for different pages.....and I dont think you will loose out on your main title people see when they first come to your site because the default.aspx or whatever you may have changed your start page too should have its own title code..

I hope this isnt too confusing....and I hope it helps you out a bit.
MaxBounty
Internet Marketing Center
Agloco | Own The Internet
0
minidak03
8/29/2006 6:49:54 PM
oops sorry forgot to mention also that you could probably do the same with your meta content....Try leaving it out of your masterpage code and put it in seperatly for the content pages.....this should work like the title solution above.
MaxBounty
Internet Marketing Center
Agloco | Own The Internet
0
minidak03
8/29/2006 6:53:22 PM

Sorry for all the posts ideas just keep comming........here is just some code of what I mean

 Master page code

<%@ Master Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        </asp:contentplaceholder>
    </div>
    </form>
</body>
</html>

 Then Your Default.aspx Code

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Starting Page</title>
    <meta content="whatever you like to put for your meta tags just toss them in here."/>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

 

And finally another content page

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <!--A ENTIRELY NEW TITLE FOR AN ENTIRELY NEW PAGE STILL CONTECTED TO YOUR MASTERPAGE BUT ALL HAVE
    DIFFERENT TITLES AND META TAGS-->
    <title>Second Content Page</title>
<meta content="Again a whole new area for your content" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

 I know these are not all correct for connecting to the masterpage but it kinda helps get my point accross in a visual manner.


MaxBounty
Internet Marketing Center
Agloco | Own The Internet
0
minidak03
8/29/2006 7:02:42 PM

The examples you give dont seem to show the content pages as being linked to the master page.  When I try and put separate head and title tags in each content page e.g. aboutus.aspx, contact.aspx etc it says "only content controls are allowed directly in a content page that contains content controls"or if i then put it inside the content control area.  It gives an error of "you can only have one <head runat="server"> control on a page.


Current project: Cycle round the world
0
ajw
8/30/2006 8:52:49 AM
hello ajw, I am sorry that my suggestions did not work out for you.......I found some very good tutorials located here http://www.123aspx.com/Directory.aspx?dir=69 and I came accross your problem solver in the masterpages section of this webpage I am sure you can find out what the problem is there.....I am not sure of the exact page that I seen it on because I was just saving about 30 of them all together as one big tutorial but none the less there are is a ton of usefull information located there.
MaxBounty
Internet Marketing Center
Agloco | Own The Internet
0
minidak03
9/3/2006 10:37:10 PM

I have provided an answer to this here:

 

http://forums.asp.net/thread/1385821.aspx


Current project: Cycle round the world
0
ajw
9/12/2006 10:23:12 AM
Reply:

Similar Artilces:

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

Show content in both Master Page ContentPlaceholder AND Content Page Content control
I note that by default or rendering rules, when you add content/controls to the Content Page ASP:Content control matched to a Master Page ContentPlaceholder, any content/controls in the matching Master Page ContentPlaceholder is not displayed. Is there a setting that can be made to merge or show both content/controls in the Master Page ContentPlaceholder and content/controls in the matching Content Page Content control? Thanks         Don't think so. If you specify a content control in your page then whatever is in there displays and anything in the...

Using an Update Panel in a Content page of Master.page/content.page scenario
When I place an Update Panel inside a content page of a Masterpage I get the following error: Element 'UpdatePanel' is not a known element. This can occur if there is a compilation error in the Web site.  Is the Update Panel suppose to work with a content page, etc.?  Can't seem to find any Docs that talk about where the Update Panel is allowed. Warren     Well, don't you know it.  Right after I put out the original post, I then downloaded the latest release of the ajax extensions and it looks like they have fixed the problem with the update panel not working ...

CSS not accessable from content page when Master Page and Content Pages are in different folder.
I can't seem to find a solution to this problem.  I have a master page and content pages and a CSS file all in the root folder.  I have created a sub folder called News and have added a content page that references the master page in the root directory with the following: MasterPageFile="~/Default.master". The issue is that the page in the News folder is not picking up the CSS styles from the master page.  Has anybody else ran into a problem like this and was able to find a solution? Any help would be greatly appreciated? Thanks, Neeraj    N...

Using Master Page controls in content pages..
Dear All I am new to using Master pages but i find them very usefull. What I have is on the master page is a menu that consists of series of link buttons that link to different content pages and a series of panels that contains an image of a bar that correspondes to a button, and I wont to set the visibility of a panel to true or false depending on the click of a link button. The problem is the panels on the master page seem to be protected, and when i go to reference the control in the content page i cant even though the content page now about the control. here is the code i am using...

Content controls are allowed only in content page that references a master page.
HiI'm getting the above error with my application.Basically I had a master file and then some page files referencing the master file.In the page files I had some ajax controls so had :<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><atlas:ScriptManager ID="ScriptManager1" runat="server"></atlas:ScriptManager>in them.but when I try adding an ajax control to the master file and putting the above code in, it shows the error messagewhy would this be?thanks!  Make sure you have prop...

convertion from page to content page or from user control to content page
Hi, I have converted an asp.net 1.1 application to 2.0.  Now what I am looking for some enhancement.  I added a master page and now I want to add other pages as content pages. but those pages which I am converting into content have some user control. Now either I can convert those user control to content pages ( which i want to look for if it is possible),  Or I am thinking i shouldn't convert those user control to content pages cause they might be just good. So looking for some of those people opinion who have worked through this so can I get opinion here please.thanks&nb...

Using a master page, how can you have different header images for different pages that are outside of the content placeholder?
I want the majority of the pages to be identical.  At the top of the page I have an image, below that navigation, and below that a table with three columns.  The outside columns content will remain the same, with the content placeholder in the center.   My question is, is there anyway that I can change the header image on the individual webforms to replace the image associated with the master page?   Thanks in advance for any help. Eric Yes.Create a property in you masterpage that allows you to set the ImageUrl for your imageFor instance,public string Hea...

MASTER PAGE AND CONTENT PAGE USING DIFFERENT LANGUAGE
Dear all, I have a big problem now. I use C# to write for master page. I have some pages using C#, some pages using VB.NET. When I run, return errors saying that content pages use different language with master page. Because this is group project, but we forget to discuss which language to use for the whole project. Anyone knows how to solve this problem. I really appreciate your help! Best wishes, SUSAN Well, someone is going to have to re-write, because you can't use more than one language.  How you decide who this is going to be is up to you, but some ideas would include: ...

Error:Content controls are allowed only in content page that references a master page?!!
 Hello All I have a web application, it is working well in localost without any error but when I upload it to the host it show me the error below:Any suggestion? I have not seen this error beforePlease any helpRegards, Server Error in '/' Application. Content controls are allowed only in content page that references a master page. Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code. Ex...

error: Content controls are allowed only in content page that references a master page.
 I have a website that uses a masterpage. most of my users have no problem; but few get the error bellow. I was never able to duplicate the error.   ex.message: Content controls are allowed only in content page that references a master page.Stack trace:    at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)   at System.Web.UI.Page.get_Master()   at System.Web.UI.Page.ApplyMasterPage()   at System.Web.UI.Page.ProcessRequestMain(Boolean in...

Web resources about - Different head content for content pages using one Master page - asp.net.navigation-controls

Marc Anthony Becomes Latest Celebrity To Bash Trump: ‘F**k Donald Trump’
American singer Marc Anthony has joined the increasing list of celebrities who have taken to bashing Republican presidential candidate Donald ...

Why India rejected Facebook's 'free' version of the Internet
It's hard to remember, but things looked good for Facebook 's ambitions in India last fall. "India has 600,000 villages, and most people get ...

Obama Asks for $19 Billion Cybersecurity Boost
More President Obama Sends $4 Trillion Budget to Congress Federal Budget Deficit Will Rise to $544 Billion This Year (WASHINGTON) — The federal ...

Police Chief says 12-year-old girls who take nude selfies are "guilty"
Peters, Pennsylvania Police Chief Harry Fruch has ordered his police force to investigate middle school students who are taking and sharing naked ...

Hackers are offering to pay $23,000 for valid Apple employee login details
Apple has a high regard for security and secrecy, but that doesn’t mean hackers have simply given up the dream of accessing this particular fortress. ...

How Oscar Best Picture Nominees Aim to Stay Relevant
From the Pope and the Vatican to D.C. movers and shakers, this year's Oscar players make their best pitch for relevance.

Nine dead, 50 seriously injured after head-on train crash in Bavaria, Germany
CNN Nine dead, 50 seriously injured after head-on train crash in Bavaria, Germany CNN (CNN) Nine people are dead, two are assumed missing ...

Google allows Adblock Fast back in Play store, after pulling the app last week and slowing app updates ...
Sarah Perez / TechCrunch : Google allows Adblock Fast back in Play store, after pulling the app last week and slowing app updates for other ad ...

Jeremy Sisto To Star In ABC Pilot ‘The Jury’
Jeremy Sisto is set to co-star opposite Archie Panjabi in ABC's murder trial drama pilot The Jur y, from Sony TV and ABC Studios. Written by ...

Valentine’s Day: Does Facebook Ad Spend Mirror Gift Purchases?
Valentine’s Day falls on Feb. 14, but Feb. 11 is the key day for advertisers on Facebook, according to a new study from Nanigans . The digital ...

Resources last updated: 2/9/2016 7:05:28 PM