473,395 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Set title in master page

Hi,

How do I set the title in a master page from a content page, assuming that I don't set the content page's title property in
the .aspx file but rather in the codebehind file? (The reason I ask is because the title in the content page is dynamic.)

Thanks,
Roshawn
Jan 9 '07 #1
10 1861
"Roshawn" <ra*********@yahoo.comwrote in message
news:eM**************@TK2MSFTNGP02.phx.gbl...
How do I set the title in a master page from a content page
Header.Title = "......";
Jan 9 '07 #2
How about this code?

Me.Master.Page.Title = "Whatever"

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Roshawn" <ra*********@yahoo.comwrote in message
news:eM**************@TK2MSFTNGP02.phx.gbl...
Hi,

How do I set the title in a master page from a content page, assuming that
I don't set the content page's title property in the .aspx file but rather
in the codebehind file? (The reason I ask is because the title in the
content page is dynamic.)

Thanks,
Roshawn
Jan 9 '07 #3
Thanks for the reply, Steve. Unfortunately, this doesn't work. :-(
Jan 9 '07 #4
Hi Mark and thanks for the reply. I gave your suggestion a try but no results. The master page ignores it, although no
errors are thrown.
Jan 9 '07 #5
Hey, I've got it!!! :-)

I declared a variable as an HtmlTitle and set its text property. When done I added this variable to the controls collection
of the content page's headers property. It looks like this:

Dim html As New HtmlTitle

html.Text = "Some Name Here"

Me.Headers.Controls.Add(html)

Cheers,
Roshawn
Jan 9 '07 #6
"Roshawn" <ra*********@yahoo.comwrote in message
news:uD**************@TK2MSFTNGP03.phx.gbl...
Hey, I've got it!!! :-)

I declared a variable as an HtmlTitle and set its text property. When
done I added this variable to the controls collection of the content
page's headers property. It looks like this:

Dim html As New HtmlTitle

html.Text = "Some Name Here"

Me.Headers.Controls.Add(html)
Good that you've got it working, but I've never seen that method before...

Header.Title = "..." has always worked for me...

Anyone know why it doesn't work for the OP...?
Jan 9 '07 #7
My bad!! :-( It actually does work. The title is derived from a querystring value. Stupid (that's me) forgot to get that
value.

Oh well, who says that you can be a genius everyday. :-)

Cheers,
Roshawn
Jan 9 '07 #8
"Roshawn" <ra*********@yahoo.comwrote in message
news:eF**************@TK2MSFTNGP04.phx.gbl...
My bad!! :-( It actually does work. The title is derived from a
querystring value. Stupid (that's me) forgot to get that value.
Fab! Thought I was going mad there...
Jan 9 '07 #9
I would say the other suggested methods are not working because the content
page requires a cast to the Master to reference its members. That's why the
OP probably has no Intellisense in the content page for any members of the
Master as well.

Go to http://www.odetocode.com where Scott Allen has written up perhaps the
best articles providing insight into the use of MasterPages. Dino Espinoza
reviews these issues in the latest aspnet.Pro magazine where Steve Orr who
commented in this news topic also wrote up a second article about passing
values between pages. Good stuff...

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP http://wikimapia.org/#y=43038073&x=-...8&z=17&l=0&m=h
"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:uu**************@TK2MSFTNGP02.phx.gbl...
"Roshawn" <ra*********@yahoo.comwrote in message
news:eF**************@TK2MSFTNGP04.phx.gbl...
>My bad!! :-( It actually does work. The title is derived from a
querystring value. Stupid (that's me) forgot to get that value.

Fab! Thought I was going mad there...

Jan 9 '07 #10
This is the way I did it. I have a string variable in the code-behind
which contains a string that I want to use as the title.

Create a protected property in the code behind

private string _myPageHeader;
..
..
..
protected string MyPageHeader
{
get { return _myPageHeader; }
}

In the <title</titletags do the following:-

<title>
<% Response.Output.Write (MyPageHeader); %>
</title>

Works for me!

*** Sent via Developersdex http://www.developersdex.com ***
Jan 18 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
1
by: Dunc | last post by:
Hi, I'm using ASP.NET 2.0's master pages feature (very nice), and I'm setting the page title programatically (Master.Page.Title = "abc";) based on a database read. Whenever a button is pushed...
4
by: David Thielen | last post by:
Hi; If I am using master pages, how do I set the <title> and <meta name='description' content='my title'> for each page. Obviously each page will have a different title & description. --...
3
by: John | last post by:
I'm using a master page for my web site and I want to show the account name in the master page 'title' section. How can I show my drop down selection in my master page 'title section'? example:...
3
by: musosdev | last post by:
Hi guys I'm using a MasterPage for my website rebuild (vs2005, .net2, c#). I want to be able to control the Title element, both on the MasterPage and the Content pages. For example, on each...
3
by: Mike P | last post by:
How do you set the title of content pages? I can set the title of my master pages, but I want each of my content pages to have a different title. *** Sent via Developersdex...
6
by: Rippo | last post by:
Is it possible to turn off the title tag in the page directive when using master pages? We have got meta data and title defined in a content control and are ending up with 2 title tags, one...
0
by: Abraham Andres Luna | last post by:
hello everyone, i just wanted to know if there was a workaround, or maybe it's just a bug. i have a master page: basepage.master <%@ Master %> <html> <head runat="server"> <title>CRM...
1
by: indirareddy | last post by:
Hai ... I Did One Project Without Title . How To Applied Title Name . Note :- I Have Using Master Page it is possible to write title in Default .aspx Example :-
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.