Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > title section dynamically

Reply
Thread Tools

title section dynamically

 
 
Dariusz Tomon
Guest
Posts: n/a
 
      05-05-2006
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
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      05-05-2006
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
 
Swanand Mokashi
Guest
Posts: n/a
 
      05-05-2006
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
 
Dariusz Tomon
Guest
Posts: n/a
 
      05-06-2006
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
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      05-06-2006
<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
 
Dariusz Tomon
Guest
Posts: n/a
 
      05-06-2006
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
 
Laurent Bugnion, GalaSoft
Guest
Posts: n/a
 
      05-15-2006
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
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      05-15-2006
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
 
Laurent Bugnion
Guest
Posts: n/a
 
      05-15-2006
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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I dynamically add a <style> to the <head> section of ASP.NET page? Ken Varn ASP .Net 7 05-10-2010 03:35 AM
Set Page title dynamically SStory ASP .Net 5 05-25-2004 01:00 AM
How to change page's title dynamically Guogang ASP .Net 6 01-23-2004 11:14 PM
dynamically visible section: How to? Does it work in Netscape 4.7? NotGiven Javascript 6 12-23-2003 12:06 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57