How to get the page name of itself

A

ad

I am use VS2005 to develop a web application.
How can I get the page name(the name of .aspx file) of it self in the page
class?
 
J

Juan T. Llibre

VB.NET :
Dim name as string = System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME"))

C# :
string name = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);

If you need to get it in codebehind, use HttpContext.Current
 
C

clintonG

Check out these two new properties too...

Page.Title = Page.AppRelativeTemplateSourceDirectory;
Page.Title = Page.AppRelativeVirtualPath;


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



Juan T. Llibre said:
VB.NET :
Dim name as string =
System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME"))

C# :
string name =
System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);

If you need to get it in codebehind, use HttpContext.Current





ad said:
I am use VS2005 to develop a web application.
How can I get the page name(the name of .aspx file) of it self in the
page class?
 
J

Juan T. Llibre

When working with relative paths, those are very handy indeed.

See what they return at :

http://asp.net.do/test/apppath.aspx





clintonG said:
Check out these two new properties too...

Page.Title = Page.AppRelativeTemplateSourceDirectory;
Page.Title = Page.AppRelativeVirtualPath;


<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/



Juan T. Llibre said:
VB.NET :
Dim name as string = System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME"))

C# :
string name = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);

If you need to get it in codebehind, use HttpContext.Current





ad said:
I am use VS2005 to develop a web application.
How can I get the page name(the name of .aspx file) of it self in the page class?
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top