472,122 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

Change Page Title (ASPX 2.0)

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,




Mar 9 '06 #1
5 3434
Try this.Title =
ConfigurationManager.AppSetting["WebSiteName"].toString();

Mar 9 '06 #2
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" <ml@cista.be> wrote in message
news:eO**************@TK2MSFTNGP11.phx.gbl...
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,






Mar 9 '06 #3
Try this.Title =
ConfigurationManager.AppSetting["WebSiteName"].toString();


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

Thanks,
Mar 9 '06 #4
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,




Mar 9 '06 #5
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.
Mar 10 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Guogang | last post: by
7 posts views Thread by GaryDean | last post: by
10 posts views Thread by _Who | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.