Finding out the name of the current aspx page.

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

Hi,

Does anyone know if its possible to find out the name of the current page,
less any directories in front of it? I just want the page.aspx part

Thanks all

Simon
 
Hi Simon,

There are probably other ways, but it is simple enough to parse it out:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim strScriptName As String
Dim intPos As Integer
strScriptName = Request.ServerVariables("script_name")
intPos = strScriptName.LastIndexOf("/")
Response.Write(Right(strScriptName, Len _
(strScriptName) - intPos - 1))
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
 
Back
Top