473,379 Members | 1,377 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,379 software developers and data experts.

title section dynamically

Hi

Is it possible to change dynamically <title></title> section in page. What I
want is to have <title> section depended on values retrieved from database.
The question could be extended to other sections from <HEAD> section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek
May 5 '06 #1
8 1166
In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
ASP.NET 1.1 you can put a Literal control in the title tag.

Dariusz Tomon wrote:
Hi

Is it possible to change dynamically <title></title> section in page. What I
want is to have <title> section depended on values retrieved from database.
The question could be extended to other sections from <HEAD> section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek

May 5 '06 #2
If you are using Master pages with ASP.NET 2.0 you can see the power of ~
here :
http://www.dotnetgenerics.com/Module...erOfTilda.aspx

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"Göran Andersson" <gu***@guffa.com> wrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
ASP.NET 1.1 you can put a Literal control in the title tag.

Dariusz Tomon wrote:
Hi

Is it possible to change dynamically <title></title> section in page.
What I want is to have <title> section depended on values retrieved from
database. The question could be extended to other sections from <HEAD>
section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek

May 5 '06 #3
unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?

Best Regards

Darek T.

"Göran Andersson" <gu***@guffa.com> wrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
ASP.NET 1.1 you can put a Literal control in the title tag.

Dariusz Tomon wrote:
Hi

Is it possible to change dynamically <title></title> section in page.
What I want is to have <title> section depended on values retrieved from
database. The question could be extended to other sections from <HEAD>
section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek

May 6 '06 #4
<title><asp:Literal id="asdf" runat="server"/></title>

asdf.Text = "First page";

Dariusz Tomon wrote:
unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?

Best Regards

Darek T.

"Göran Andersson" <gu***@guffa.com> wrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
ASP.NET 1.1 you can put a Literal control in the title tag.

Dariusz Tomon wrote:
Hi

Is it possible to change dynamically <title></title> section in page.
What I want is to have <title> section depended on values retrieved from
database. The question could be extended to other sections from <HEAD>
section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek


May 6 '06 #5
ok - it works - thank you

"Göran Andersson" <gu***@guffa.com> wrote in message
news:OH**************@TK2MSFTNGP04.phx.gbl...
<title><asp:Literal id="asdf" runat="server"/></title>

asdf.Text = "First page";

Dariusz Tomon wrote:
unfortunatelly I'm using ASP.NET 1.1 so could you provide an example?

Best Regards

Darek T.

"Göran Andersson" <gu***@guffa.com> wrote in message
news:O1**************@TK2MSFTNGP04.phx.gbl...
In ASP.NET 2.0 you can use Page.Title to set the title of the page. In
ASP.NET 1.1 you can put a Literal control in the title tag.

Dariusz Tomon wrote:
Hi

Is it possible to change dynamically <title></title> section in page.
What I want is to have <title> section depended on values retrieved
from database. The question could be extended to other sections from
<HEAD> section.
If it's possible please provide an example (ideally in C#).

Best Regards

Darek


May 7 '06 #6
Hi,

Göran Andersson wrote:
<title><asp:Literal id="asdf" runat="server"/></title>

asdf.Text = "First page";


I prefer this way:

<title runat="server" id="pageTitle">Default title</title>

and then:

HtmlGenericControl windowTitle
= FindControl( "title" ) as HtmlGenericControl;

if( windowTitle == null )
throw new ApplicationException( "..." );

windowTitle.InnerHtml = "My title";

HTH
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
May 15 '06 #7
Laurent Bugnion, GalaSoft wrote:
Hi,

Göran Andersson wrote:
<title><asp:Literal id="asdf" runat="server"/></title>

asdf.Text = "First page";


I prefer this way:

<title runat="server" id="pageTitle">Default title</title>

and then:

HtmlGenericControl windowTitle
= FindControl( "title" ) as HtmlGenericControl;

if( windowTitle == null )
throw new ApplicationException( "..." );

windowTitle.InnerHtml = "My title";

HTH
Laurent


Doesn't the FindControl use the id rather than the tag name?

Why use FindControl ayway when you can reference the control directly?
May 15 '06 #8
Hi,

Göran Andersson wrote:
Laurent Bugnion, GalaSoft wrote:
<title runat="server" id="pageTitle">Default title</title>

and then:

HtmlGenericControl windowTitle
= FindControl( "title" ) as HtmlGenericControl;

if( windowTitle == null )
throw new ApplicationException( "..." );

windowTitle.InnerHtml = "My title";
Doesn't the FindControl use the id rather than the tag name?


Sorry, it was a typo. This should read

HtmlGenericControl windowTitle
= FindControl( "pageTitle" ) as HtmlGenericControl;
Why use FindControl ayway when you can reference the control directly?


That's correct.

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
May 15 '06 #9

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

Similar topics

6
by: the wonderer | last post by:
This is an elementary question, but I've not been able to find the answer, so here goes: I am developing a site using php. I have the html header information in a file that I include in all the...
28
by: Atanas Boev | last post by:
I have a heading that I would like to link to site section, in the following context: <h1>Site Contents</h1> <h2>First Section</h2> <h2>Second Section</h2> <h2>Third Section</h2> I want...
6
by: Alex | last post by:
Hi, is it possible to set the title programatically from the code behind page. I placed a literal in the head section of the form and set its text property. it seemed to work bu the literal...
6
by: Guogang | last post by:
Hi, is there a way to change the page's title in code behind (C#)? I want to change this part: <HEAD> <TITLE> Can be changed dynamically. </TITLE> </HEAD> Thanks, Guogang
5
by: Maxim Izbrodin | last post by:
Hello For displaying page titles for my ASP.NET applications I use the following technique <title><%=BannerModule.PageTitle%></title where BannerModule.PageTitle is a public field of my user...
6
by: Ken Varn | last post by:
I want to add my own custom <STYLE> section in the <HEAD> section of my ASP.NET page within a custom control. Can someone tell me how I can have my custom control add tags to the <HEAD> section of...
14
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... ...
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:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.