473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 3490
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Guogang | last post by:
Hi, is there a way to change the page's title in code behind (C#)? I want to change this part: <HEAD> <TITLE> Can be changed dynamically. </TITLE> </HEAD> Thanks, Guogang
6
by: Fred | last post by:
I have implemented a dialog box (an aspx page) using showModalDialog. Because the dialog needs to process postbacks, I have implemented it in a frameset. In the top of the framset page, I have...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
3
by: Craig Wilson | last post by:
How do I programmatically change the page title in ASP.Net In general, I need to get at the object model that gets access to the title property. best wishes,
7
by: GaryDean | last post by:
In my old 1.1 apps the default was MS_POSITIONING="GridLayout" and Textboxes and labels and such always had POSITION: absolute; and I never had any distortion when the page was rendered. Life was...
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
2
by: Radu | last post by:
Hi, I have a "select" control named "cboSelectScorecardType", defined as <select id="cboSelectScorecardType" size="1" runat="server"> </select> which shows a list of files on my drive. It...
3
by: guillermojco | last post by:
Hi, I've got an ASP.NET page that returns XLS, DOC, PDF and other files from binary fields in a database. The problem is that MS-Excel 2007 shows a security warning when trying to open the...
10
by: _Who | last post by:
Seems to me that I should be able to do something like: ....runat="server" change from white.css to black.css... Of course if I could have found out how, I wouldn't be bothering you. Is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.