Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Change Page Title (ASPX 2.0)

Reply
Thread Tools

Change Page Title (ASPX 2.0)

 
 
Christian Ista
Guest
Posts: n/a
 
      03-09-2006
Hello,

I have a problem to change title page at runtime.

In the page ASPX :
<title runat="server" id="pageTitle"></title>

In code behind :
public partial class _Default : System.Web.UI.Page

In the Page_Load:
pageTitle.InnerText = ConfigurationManager.AppSettings["WebSiteName"];

But I receive this error :
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific error
details and modify your source code appropriately.

Compiler Error Message: CS0102: The type '_Default' already contains a
definition for 'pageTitle'

When I replace pageTitle.InnerText but a textbox no problem.

Any idea ?

Thanks,












 
Reply With Quote
 
 
 
 
Jacob
Guest
Posts: n/a
 
      03-09-2006
Try this.Title =
ConfigurationManager.AppSetting["WebSiteName"].toString();

 
Reply With Quote
 
 
 
 
Juan T. Llibre
Guest
Posts: n/a
 
      03-09-2006
It looks like you are missing the declaration :

protected System.Web.UI.HtmlControls.HtmlGenericControl PageTitle;

Declare the control and
pageTitle.InnerText = ConfigurationManager.AppSettings["WebSiteName"];

will start working.



Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Christian Ista" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a problem to change title page at runtime.
>
> In the page ASPX :
> <title runat="server" id="pageTitle"></title>
>
> In code behind :
> public partial class _Default : System.Web.UI.Page
>
> In the Page_Load:
> pageTitle.InnerText = ConfigurationManager.AppSettings["WebSiteName"];
>
> But I receive this error :
> Description: An error occurred during the compilation of a resource required to service this
> request. Please review the following specific error details and modify your source code
> appropriately.
>
> Compiler Error Message: CS0102: The type '_Default' already contains a definition for 'pageTitle'
>
> When I replace pageTitle.InnerText but a textbox no problem.
>
> Any idea ?
>
> Thanks,
>
>
>
>
>
>
>
>
>
>
>
>





 
Reply With Quote
 
Christian Ista
Guest
Posts: n/a
 
      03-09-2006

> Try this.Title =
> ConfigurationManager.AppSetting["WebSiteName"].toString();


This work fine : pageTitle.Text =
ConfigurationManager.AppSettings["WebSiteName"];

Thanks,


 
Reply With Quote
 
=?Utf-8?B?U3RldmUgQy4gT3Jy?=
Guest
Posts: n/a
 
      03-09-2006
You're making this harder than it needs to be.
Just use code like this:

Page.Title = "Whatever"

--
I hope this helps,
Steve C. Orr
MCSD, MVP
http://SteveOrr.net



"Christian Ista" wrote:

> Hello,
>
> I have a problem to change title page at runtime.
>
> In the page ASPX :
> <title runat="server" id="pageTitle"></title>
>
> In code behind :
> public partial class _Default : System.Web.UI.Page
>
> In the Page_Load:
> pageTitle.InnerText = ConfigurationManager.AppSettings["WebSiteName"];
>
> But I receive this error :
> Description: An error occurred during the compilation of a resource
> required to service this request. Please review the following specific error
> details and modify your source code appropriately.
>
> Compiler Error Message: CS0102: The type '_Default' already contains a
> definition for 'pageTitle'
>
> When I replace pageTitle.InnerText but a textbox no problem.
>
> Any idea ?
>
> Thanks,
>
>
>
>
>
>
>
>
>
>
>
>
>

 
Reply With Quote
 
Erik Funkenbusch
Guest
Posts: n/a
 
      03-10-2006
On Thu, 9 Mar 2006 17:51:15 +0100, Christian Ista wrote:

Every page exposes a Title property that will change the title without
having to specify a runat=server title element. Just set Title="My new
title" or whatever in your code behind.
 
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 On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>… Stéphane Klein Python 2 03-30-2010 12:35 AM
Friendly Urls with page title in (eg. page-title.aspx) anthonykallay@googlemail.com ASP .Net 1 04-24-2007 08:25 AM
How 2 place page title into window title using sitemap in master page? bednar.tomas@gmail.com ASP .Net 0 11-30-2006 03:17 PM
Does anyone know the title of the first ever DVD title released? (UK/US) Mikey DVD Video 12 09-23-2006 07:14 PM
Fastest way to get a the string between <title> </title> Andreas Klemt ASP .Net 1 08-10-2003 01:58 AM



Advertisments