title section dynamically

D

Dariusz Tomon

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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.
 
S

Swanand Mokashi

If you are using Master pages with ASP.NET 2.0 you can see the power of ~
here :
http://www.dotnetgenerics.com/Modules/TricksAndTips/ASP.NET/PowerOfTilda.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
 
D

Dariusz Tomon

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

Best Regards

Darek T.
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

<title><asp:Literal id="asdf" runat="server"/></title>

asdf.Text = "First page";
 
L

Laurent Bugnion, GalaSoft

Hi,

Göran Andersson said:
<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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Hi,



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?
 
L

Laurent Bugnion

Hi,

Göran Andersson said:
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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top