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

  • Thread starter Thread starter Cal Who
  • Start date Start date
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
 
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
 
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.
 
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
 
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.
 
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, 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
 
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
 
Back
Top