how to get the name of the current aspx file?

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

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
 
Dave said:
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.
 
you can get from Request.FilePath, by removing the leading dir string.

-- bruce (sqlwork.com)
 
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);
 
Back
Top