Get title of page

C

Chris Botha

Request.ServerVariables("PATH_INFO") and then strip off the path in front
if you don't want the path.
 
T

tshad

Chris Botha said:
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
 
C

Chris Botha

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.
 
J

Juan T. Llibre

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top