Re: ASP.net File name

Discussion in 'ASP .Net' started by Ken Cox [Microsoft MVP], May 11, 2004.

  1. You can always 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

    "Sunil Sabir" <> wrote in message
    news:...
    > Dear all,
    >
    > I am actually trying to get the File name of my ASP.net page. I am
    > using this property of Page class
    >
    > Response.Write(Page.Page)
    >
    > and it gives me the following output:
    >
    > ASP.WebForm2_aspx
    >
    > which I dont need. I need it to be like this:
    >
    > WebForm2.aspx
    >
    > Any help very much appreciated.
     
    Ken Cox [Microsoft MVP], May 11, 2004
    #1
    1. Advertising

  2. Ken, why not use the System.IO.Path class and let it handle parsing out
    file names from a path? :)


    Ken Cox [Microsoft MVP] wrote:
    > You can always 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
    > [snip]


    --

    Scott Mitchell

    http://www.4GuysFromRolla.com
    http://www.ASPFAQs.com
    http://www.ASPMessageboard.com

    * When you think ASP, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], May 11, 2004
    #2
    1. Advertising

  3. Maybe 'cause I didn't think about it? <grin>

    "Scott Mitchell [MVP]" <> wrote in message
    news:pm8oc.7236$...
    > Ken, why not use the System.IO.Path class and let it handle parsing out
    > file names from a path? :)
    >
    >
    > Ken Cox [Microsoft MVP] wrote:
    >> You can always 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
    > > [snip]

    >
    > --
    >
    > Scott Mitchell
    >
    > http://www.4GuysFromRolla.com
    > http://www.ASPFAQs.com
    > http://www.ASPMessageboard.com
    >
    > * When you think ASP, think 4GuysFromRolla.com!
     
    Ken Cox [Microsoft MVP], May 11, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    829
    Roedy Green
    Jan 2, 2006
  2. ding feng
    Replies:
    2
    Views:
    2,821
    ding feng
    Jun 25, 2003
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,400
    Joe Smith
    Apr 22, 2007
  4. Jack-2
    Replies:
    3
    Views:
    272
    Jack-2
    Dec 24, 2003
  5. Java  script  Dude

    IE name="name" & form.name property bug

    Java script Dude, Jun 29, 2004, in forum: Javascript
    Replies:
    5
    Views:
    246
    Java script Dude
    Jun 30, 2004
Loading...

Share This Page