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

Get title of page

Is there an easy way to get the title of the aspx page I am on?

Thanks,

Tom
Nov 19 '05 #1
6 1496
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?


Or the filename of the page, which would be better.

Thanks,

Tom
Nov 19 '05 #2
Request.ServerVariables("PATH_INFO") and then strip off the path in front
if you don't want the path.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?


Or the filename of the page, which would be better.

Thanks,

Tom

Nov 19 '05 #3
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
Request.ServerVariables("PATH_INFO") and then strip off the path in front
if you don't want the path.
I assume this works everytime, unlike the HTTP_REFERER?

Thanks,

Tom
"tshad" <ts**********@ftsolutions.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?


Or the filename of the page, which would be better.

Thanks,

Tom


Nov 19 '05 #4
Well, give it a shot and see, it is the same as the old asp
Request.ServerVariables("PATH_INFO") before dotnet. It may give an invalid
name if you do a Server.Transfer call in the code-behind, other than that it
should work.
"tshad" <ts**********@ftsolutions.com> wrote in message
news:OL**************@TK2MSFTNGP15.phx.gbl...
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
Request.ServerVariables("PATH_INFO") and then strip off the path in
front if you don't want the path.


I assume this works everytime, unlike the HTTP_REFERER?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?

Or the filename of the page, which would be better.

Thanks,

Tom



Nov 19 '05 #5
What about something like Page.Request.Url?
"tshad" <ts**********@ftsolutions.com> wrote in message
news:OL**************@TK2MSFTNGP15.phx.gbl...
"Chris Botha" <ch***********@AThotmail.com> wrote in message
news:eT**************@tk2msftngp13.phx.gbl...
Request.ServerVariables("PATH_INFO") and then strip off the path in
front if you don't want the path.


I assume this works everytime, unlike the HTTP_REFERER?

Thanks,

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eE**************@TK2MSFTNGP11.phx.gbl...
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?

Or the filename of the page, which would be better.

Thanks,

Tom



Nov 19 '05 #6
Add a ID=”whatever” and a Runat=”Server”
to the Title element on the aspx page.

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

Then, in code-behind :

protected System.Web.UI.HtmlControls.HtmlGenericControl pageTitle;
pageTitle.InnerText = "Whatever you want to place here -” + anyvariable ;

If you want to get the aspx page's name, per your followup post, use :

string pagename = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);

That will return : "WhateverThePageNameIs.aspx".
You can insert that value in the "anyvariable" variable.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"tshad" <ts**********@ftsolutions.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Is there an easy way to get the title of the aspx page I am on?

Thanks,

Tom


Nov 19 '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
50
by: MozillaCensorsMe | last post by:
Hello, While I haven't finished my wonderful tutorial to save the world, I do have a simple question. What's the difference between h1 and the title tag? For me it seems as though both can...
3
by: Andy Dingley | last post by:
We've all seen this structure many times: <ul> <li><a href="..." >Click here</a></li> <li><a href="..." >Click here</a></li> </ul> Now it's obvious good practice to have sensible link texts,...
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...
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...
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>..... ...
2
by: Nathan Sokalski | last post by:
I would like to change the <title></title> of a page from a user control. I have been unable to find any property in VB that allows me to do this. The only thing I have been able to find that might...
1
by: Alan Silver | last post by:
Hello, I am just experimenting with master pages, and am trying to add a content placeholder in the <head> section, so that individual pages can set their own page title and meta tags. The...
6
by: Rippo | last post by:
Is it possible to turn off the title tag in the page directive when using master pages? We have got meta data and title defined in a content control and are ending up with 2 title tags, one...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.