473,385 Members | 1,641 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,385 software developers and data experts.

Chenge WEB page title

Val
How do i programmatically change a title of a Web page in ASP.NET?

Thanks
Nov 17 '05 #1
6 1619
Val

<title><%if(Condition){Response.Write("Title A");}else{Response.Write("Title
B");}%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
How do i programmatically change a title of a Web page in ASP.NET?

Thanks

Nov 17 '05 #2
One day, Mark White wrote:
Val

<title><%if(Condition){Response.Write("Title
A");}else{Response.Write("Title B");}%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
How do i programmatically change a title of a Web page in ASP.NET?

Thanks


We could actually streamline this a bit:

///
<title><%=(condition) ? "Title A" : "Title B" %></title>
///

--
Tom Spink
Nov 17 '05 #3
Val
That does not work from CodeBehind file (aspx.cs)! Is there an
object/property that I can change to change title?

Thanks

"Mark White" wrote:
Val

<title><%if(Condition){Response.Write("Title A");}else{Response.Write("Title
B");}%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
How do i programmatically change a title of a Web page in ASP.NET?

Thanks


Nov 17 '05 #4
Ok, what you can do is have a protected string as a member var. of the
code-behind.
protected string sTitle = "";

In Page_Load or wherever you want, throw the logic in it to determine the
value of your title string.
if(Condition)
{
sTitle = "Title A";
}
else
{
sTitle = "Title B";
}

In the front-end .aspx page:
<title><%=sTitle%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
That does not work from CodeBehind file (aspx.cs)! Is there an
object/property that I can change to change title?

Thanks

"Mark White" wrote:
Val

<title><%if(Condition){Response.Write("Title A");}else{Response.Write("Title B");}%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
How do i programmatically change a title of a Web page in ASP.NET?

Thanks


Nov 17 '05 #5
In the html file add:

<title id="myTitle" runat="server" />

In the code behind add a field:

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

In page_load add:

myTitle.InnerText = "Hello World";

You can adapt it however you wish from there.

--

Derek Davis
dd******@gmail.com

"Val" <Va*@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
That does not work from CodeBehind file (aspx.cs)! Is there an
object/property that I can change to change title?

Thanks

"Mark White" wrote:
Val

<title><%if(Condition){Response.Write("Title
A");}else{Response.Write("Title
B");}%></title>

Mark

"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
> How do i programmatically change a title of a Web page in ASP.NET?
>
> Thanks


Nov 17 '05 #6
VS2003 mangles the HTML title element when moving between the designer and
code behind so all of those other comments have been proven risky and a PITA
to use. Thus, the better strategy is to use a Literal control in the <head>
element

// .aspx
<head><asp:Literal id="pageTitle" /></head>

// .cs
pageTitle.Text = "Home Page";
<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


"Val" <Va*@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
How do i programmatically change a title of a Web page in ASP.NET?

Thanks

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: the wonderer | last post by:
This is an elementary question, but I've not been able to find the answer, so here goes: I am developing a site using php. I have the html header information in a file that I include in all the...
6
by: Don Grover | last post by:
How can I get the page title into an variable to handle in my asp. Don
1
by: alex | last post by:
Hi ! I couldn't make backups with our new system using db2 8.2. Every time I trigger a backup I get this error message: BACKUP DATABASE EBUERO2 ONLINE TO "/raid/backup/ebuero2/part1",...
5
by: Maxim Izbrodin | last post by:
Hello For displaying page titles for my ASP.NET applications I use the following technique <title><%=BannerModule.PageTitle%></title where BannerModule.PageTitle is a public field of my user...
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...
14
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... ...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
21
by: karen987 | last post by:
I have a news website, with asp pages. It has publishing software which allows you to add articles in a database, and then calls them up from links etc. I have added dynamic meta tags in 2 parts. The...
4
osward
by: osward | last post by:
I had made a table colum sortable and paging the table, following are the code // Display Event List echo "<center>"._EVENTLIST."</center><br>"; $now = Date(Y-m-d); // sort table...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.