Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - title section dynamically

 
Thread Tools Search this Thread
Old 05-05-2006, 10:51 AM   #1
Default 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




Dariusz Tomon
  Reply With Quote
Old 05-05-2006, 11:20 AM   #2
=?ISO-8859-1?Q?G=F6ran_Andersson?=
 
Posts: n/a
Default Re: title section dynamically

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

  Reply With Quote
Old 05-05-2006, 01:15 PM   #3
Swanand Mokashi
 
Posts: n/a
Default Re: title section dynamically

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" <> wrote in message
news:...
> 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



  Reply With Quote
Old 05-06-2006, 09:30 PM   #4
Dariusz Tomon
 
Posts: n/a
Default Re: title section dynamically

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

Best Regards

Darek T.

"Göran Andersson" <> wrote in message
news:...
> 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



  Reply With Quote
Old 05-06-2006, 10:06 PM   #5
=?ISO-8859-1?Q?G=F6ran_Andersson?=
 
Posts: n/a
Default Re: title section dynamically

<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" <> wrote in message
> news:...
>> 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

>
>

  Reply With Quote
Old 05-06-2006, 11:50 PM   #6
Dariusz Tomon
 
Posts: n/a
Default Re: title section dynamically

ok - it works - thank you

"Göran Andersson" <> wrote in message
news:...
> <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" <> wrote in message
>> news:...
>>> 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

>>


  Reply With Quote
Old 05-15-2006, 01:57 PM   #7
Laurent Bugnion, GalaSoft
 
Posts: n/a
Default Re: title section dynamically

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
  Reply With Quote
Old 05-15-2006, 06:34 PM   #8
=?ISO-8859-1?Q?G=F6ran_Andersson?=
 
Posts: n/a
Default Re: title section dynamically

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?
  Reply With Quote
Old 05-15-2006, 08:33 PM   #9
Laurent Bugnion
 
Posts: n/a
Default Re: title section dynamically

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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump