In the .master code how to get the title defined in context <%@ Page

C

Cal Who

I'm using a master page.

For each context page I need to add a meta tag containing the title of that
page:
<meta name="title" content="This is the Title" />

Be nice if didn't have to insert the meta tag into each page since there is
many of them.

Since my <%@ Page line already has the title in it, it would be nice if I
could lift it using code in the master page and create the meta tag there.

Do you know how that can be done.

hanks
 
L

Lee Atkinson

Could add the meta dynamically like this on a basepage -

Dim head As HtmlHead = CType(Page.Header, HtmlHead)

Dim title as New HtmlMeta()
Title.id = "sdsds"
title.Content = page.title
head.Controls.Add(title)


Lee
 
J

James Parker

Cal Who said:
I'm using a master page.

For each context page I need to add a meta tag containing the title of
that page:
<meta name="title" content="This is the Title" />

Be nice if didn't have to insert the meta tag into each page since there
is many of them.

Since my <%@ Page line already has the title in it, it would be nice if
I could lift it using code in the master page and create the meta tag
there.

Do you know how that can be done.

hanks

The master page has a title properity like all other page types, by setting
the page title in the master page all pages using that master page will also
get that title.
 
C

Cal Who

James Parker said:
The master page has a title properity like all other page types, by
setting the page title in the master page all pages using that master page
will also get that title.

I've been adding a title to the <%@ Page line on each page which is what I
want - different titles for different pages.
I also have one in the head on the master. It does not appear to override
the ones on the <%@ Page (which is good).
In fact it appears to do nothing. Maybe if a <%@ Page didn't have a title
the master title would be effective??

Thanks
 
G

Göran Andersson

Cal said:
I've been adding a title to the <%@ Page line on each page which is what I
want - different titles for different pages.
I also have one in the head on the master. It does not appear to override
the ones on the <%@ Page (which is good).
In fact it appears to do nothing. Maybe if a <%@ Page didn't have a title
the master title would be effective??

Yes, if you omit the title attribute in a Page directive, the default
title from the master page will be used.
 
G

Guest

I've been adding a title to the <%@ Page  line on each page which is what I
want - different titles for different pages.
I also have one in the head on the master. It does not appear to override
the ones on the  <%@ Page (which is good).
In fact it appears to do nothing. Maybe if a <%@ Page didn't have a title
the master title would be effective??

Thanks- Hide quoted text -

- Show quoted text -

You can find more on MSDN regarding this behavior. Quote: "The @Page
directive binds the content page to a specific master page, and it
defines a title for the page that will be merged into the master
page."
"http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

This means that using master pages you predefine title and other
layout elements, but when you want to overwrite it, you should define
it in the content page.
 
C

Cal Who

Thanks, I used it and it works.

Thanks again

Lee Atkinson said:
Could add the meta dynamically like this on a basepage -

Dim head As HtmlHead = CType(Page.Header, HtmlHead)

Dim title as New HtmlMeta()
Title.id = "sdsds"
title.Content = page.title
head.Controls.Add(title)


Lee
 
C

Cal Who

I've been adding a title to the <%@ Page line on each page which is what I
want - different titles for different pages.
I also have one in the head on the master. It does not appear to override
the ones on the <%@ Page (which is good).
In fact it appears to do nothing. Maybe if a <%@ Page didn't have a title
the master title would be effective??

Thanks- Hide quoted text -

- Show quoted text -

You can find more on MSDN regarding this behavior. Quote: "The @Page
directive binds the content page to a specific master page, and it
defines a title for the page that will be merged into the master
page."
"http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx

This means that using master pages you predefine title and other
layout elements, but when you want to overwrite it, you should define
it in the content page.


Thanks
 

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,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top