Change Page Title (ASPX 2.0)

  • Thread starter Thread starter Christian Ista
  • Start date Start date
C

Christian Ista

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,
 
Try this.Title =
ConfigurationManager.AppSetting["WebSiteName"].toString();

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

Thanks,
 
You're making this harder than it needs to be.
Just use code like this:

Page.Title = "Whatever"
 
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.
 
Back
Top