Referring to page name

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

....still new with vb in visual studio 2005

how can I refer to the name of my .aspx page to use it in code?

E.g., I have a series of .aspx pages and each has a corresponding column in
a database that I wish to access. The column correponsing to each page has
the same name as the page. Rather than type out the column names for each
page individually, I want to do something to automatically refer to the page
name in the code. Something like, me.pagename

Jeff
 
Dim strFileName as string = Request.Url.AbsolutePath.Substring (
Request.Url.AbsolutePath.LastIndexOf("/")+1).ToLower
'strFileName.Substring(0, strFileName.LastIndexOf(".")) 'Use this if you
only need the FileName without the suffix.

There are many ways of achieving the same results

If you need to use this from a Generic class etc, then replace Request with
HttpContext.Current.Request

HTH

Trevor Benedict
MCSD
 
Back
Top