Get Physical Name of an ASP Page from a URL

Get Physical Name of an ASP Page from a URL

Sometimes we need to get the physical name (from the bar address of url) of an asp.net page to pass it by value or to loop throw project pages programmatically.


In that purpose we use a function to split the URL's string 

Public Function cutString(ByVal url As String) As String
 
      Dim St1() As String
      St1 = Split(url, "/")
 
      For i = 0 To UBound(St1)
          cutString = St1(i)
      Next i
      cutString = St1(UBound(St1))
  End Function

and then get the whole Url and use our function that extract just the name of the page with its extension(.aspx)


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  
Textbox1.Text=  cutString(Request.Url.ToString)

End Sub
Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Carsten Siemens edited Revision 1. Comment: typo

Page 1 of 1 (1 items)