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

how to get the name of the current aspx file?

Hi,

i need to get the name of the current aspx file in code-behind.
Assume the current aspx file is "myfile.aspx", i want to put value "myfile"
into a variable in code-behind.
Is that possible?

Thanks
Dave
Apr 24 '07 #1
7 3315
"Dave" <sd***@qdq.qdqwrote in message
news:eb*************@TK2MSFTNGP06.phx.gbl...
Hi,

i need to get the name of the current aspx file in code-behind.
Assume the current aspx file is "myfile.aspx", i want to put value
"myfile" into a variable in code-behind.
Is that possible?

You can get the name of the current _class_ via GetType().Name. This may or
not be the name of the file, but then I can't tell if you mean file or
class.
--

John Saunders [MVP]
Apr 24 '07 #2
you can get from Request.FilePath, by removing the leading dir string.

-- bruce (sqlwork.com)

Dave wrote:
Hi,

i need to get the name of the current aspx file in code-behind.
Assume the current aspx file is "myfile.aspx", i want to put value "myfile"
into a variable in code-behind.
Is that possible?

Thanks
Dave

Apr 24 '07 #3
"Dave" <sd***@qdq.qdqwrote in message
news:eb*************@TK2MSFTNGP06.phx.gbl...
i need to get the name of the current aspx file in code-behind.
Assume the current aspx file is "myfile.aspx", i want to put value
"myfile" into a variable in code-behind.
Is that possible?
using System.IO;
string strFile = Path.GetFileNameWithoutExtension(Request.FilePath) ;
Apr 24 '07 #4
System.IO.Path.GetFileName(Request.ServerVariables ("SCRIPT_NAME"))

....works, too.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...
"Dave" <sd***@qdq.qdqwrote in message news:eb*************@TK2MSFTNGP06.phx.gbl...
>i need to get the name of the current aspx file in code-behind.
Assume the current aspx file is "myfile.aspx", i want to put value "myfile" into a variable in
code-behind.
Is that possible?

using System.IO;
string strFile = Path.GetFileNameWithoutExtension(Request.FilePath) ;

Apr 24 '07 #5
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
System.IO.Path.GetFileName(Request.ServerVariables ("SCRIPT_NAME"))
But that will include the .aspx extension, which the OP doesn't want...
Apr 24 '07 #6
Ahhh.

I didn't read the OP's request, only your response.
Thanks...

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message news:ed**************@TK2MSFTNGP04.phx.gbl...
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>System.IO.Path.GetFileName(Request.ServerVariable s("SCRIPT_NAME"))
But that will include the .aspx extension, which the OP doesn't want...

Apr 25 '07 #7
Thanks all

"Juan T. Llibre" <no***********@nowhere.comschreef in bericht
news:uX**************@TK2MSFTNGP02.phx.gbl...
Ahhh.

I didn't read the OP's request, only your response.
Thanks...

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
>"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>System.IO.Path.GetFileName(Request.ServerVariabl es("SCRIPT_NAME"))
>But that will include the .aspx extension, which the OP doesn't want...


Apr 25 '07 #8

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

Similar topics

1
by: Ron | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
0
by: simpsoro | last post by:
I am trying to run asp.net pages. The server is accessed by students via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and...
0
by: Ron Simpson | last post by:
I am trying to run asp.net pages. The server is accessed via http://sitename/username I have verified it is using port 80 and aspx extensions are configured. But when I run and asp.net page I...
6
by: DJones | last post by:
I'm using the following code in my .Net application (.Net v1.1, Windows 2000) to write Session Cookies. HttpContext.Current.Response.Cookies("cookieSession")("SessionID") = strSessionID ...
4
by: Tiraman | last post by:
Hi, i have some problem to run my dll's (assemblies) on the production server. I have 3 dll's which use each other. Every thing is ok on my local machine where i developed them but when i...
3
by: Developer in California | last post by:
I am working on developing a generic Web framework using Master Pages in ASP.NET 2.0. What I have done is created a PageRenderer class which has a public method which will retrieve the path of the...
2
by: Abraham Andres Luna | last post by:
hello everyone, does anyone know why i can't access the HttpContext.Current.User.Identity.Name property in a .cs file? this is the index.aspx page: <%@ Page Language="C#" %> <script...
7
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file...
10
by: =?Utf-8?B?SmFtZXMgV29uZw==?= | last post by:
Hi everybody, I'm trying to use the new VB 2008 right now and I want to know how to preset the company name and copyright informtion in Assembly Information. In my current VB 2005, company name...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.