Finding out the name of the current aspx page.

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
 
K

Ken Cox [Microsoft MVP]

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top