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




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/
===================================
 
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




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/
===================================
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




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/
===================================
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




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/
===================================
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

Top