Name of Me.Page

  • Thread starter Thread starter aLEXb
  • Start date Start date
A

aLEXb

I have an ASP.NET applicaiton with a user control and I
need to determine the name of the page it resides on at
runtime. Me.Page returns the page, but how do I get just
the name? CSTR(Me.Page) causes a compile error and there
is no .ToString() on the page class.

Anyone?
 
What do you mean by page's name? Are you referring to the name of the file
as entered in the address bar in the client?

By the way, ALL classes have a ToString method since this method is defined
on the Object class. Not all methods choose to override this method and so
if you call it, the default behavior is just to output the name of the class
the instance if from.
 
If you ARE looking for just the name of the page as a file, then you
could simply do

Me.Page.Request.ServerVariables("SCRIPT_NAME")

Then just get the substring after the last occurence of "/" (SCRIPT_NAME
includesthe whole path, relative to the web app root).
 
One other note, just remember to always check before accessing
Request/Response and the like, that

Not IsNothing(Me.Context)
 
Back
Top