Last post Mar 12, 2009 12:46 PM by chris22smith
Feb 06, 2009 12:43 PM|traktorum|LINK
I want to set showad.aspx pages title dynamically. And I want to use AdTitleLabel as page title.
Any suggestions appreciated.
Thanks in advance
Feb 06, 2009 12:53 PM|AceCorban|LINK
set up your title tag like so:
<title id="titleElement" runat="server"></title>
and modify it in your codebehind as a System.Web.UI.HtmlControls.HtmlGenericControl:
public System.Web.UI.HtmlControls.HtmlGenericControl titleElement;
titleElement.InnerHtml = whateverYouLike;
Feb 06, 2009 12:58 PM|Danny117|LINK
Me.Title = adtitlelabel.text
it might me.page.title if your in a control on a page.
its built in to asp.net
Feb 06, 2009 07:05 PM|traktorum|LINK
Thank you danny but it doesn't seem to work. I receive Object reference not set to an instance of an object. error. Any Ideas ?
P.S I think Darknight can give the best answer because he used this option on his site detelli.com
Feb 07, 2009 11:23 PM|darkknight187|LINK
Thanks for the mention.
And just to let you know, I would have replied to your email,
but I've been extremely busy.
And for the record, Danny is right on his second suggestion.
So here's what I did.
I have set this code before in the page_load section.
But in your specific case of the showad page I inserted the code (vb) into the
First you should remove your hard coded title.
Title="My Hard Coded Title"
should become Title=""
Now insert the code.
metaDescription.Content = ad.Description
metaDescription.Content = ad.Description.ToString().Substring(0, 150)
That should work.
As you can see I even included code to limit the description characters to 150 characters.
Feb 08, 2009 12:16 PM|traktorum|LINK
Thank you very much Daniel,
I did everything as you explained and it works now.
Feb 08, 2009 12:45 PM|Danny117|LINK
darknight has me.page.title too!
Mar 12, 2009 12:46 PM|chris22smith|LINK
Here's another approach doing it programmatically in VB using DataView:
Setting the page title dynamically in ASP.NET