Re: How to get the page name of itself



A little bit more than that is needed.

That will return the page name *if* it's in the root.

If the page is in an application directory,
it will return a path which includes the virtual directory

You need to split the URL array to get just the page name.

Here's a routine which will return the script's name
no matter whether the page is in an application,
in the root, or in a deeply nested subdirectory.

script_name.aspx
------------------
<%@ Page Language="VB" %>
<html>
<head>
<title>Page Name</title>
</head>
<script runat="server">
Public Sub Page_Load(Sender As Object, E As EventArgs)
Dim strURL, arrayURL, pagename
strURL = Request.ServerVariables("SCRIPT_NAME")
arrayURL = Split(strURL, "/", -1, 1)
pagename = arrayURL(ubound(arrayURL))
script.text = pagename
End Sub
</script>
<html>
<body>
<form id="Form1" runat="server">
<p>
<asp:Label id="script" runat="server" /><BR>
</form>
</body>
</html>
------------




Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================

"Mark Fitzpatrick" <markfitz@xxxxxxxxxx> wrote in message
news:uH12oiqeFHA.4040@xxxxxxxxxxxxxxxxxxxxxxx
> You can find the name through the ServerVariables Collection. Use the C# example below
> to get the current page name.
>
> Request.ServerVariables["SCRIPT_NAME"].ToString()
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
>
> "ad" <ad@xxxxxxxxxxxxxxx> wrote in message
> news:%23zX5ikpeFHA.1600@xxxxxxxxxxxxxxxxxxxxxxx
>> When I a webpage, say "MyPage.aspx", How to get the page name of itsef
>> (MyPage.aspx)?
>>
>>
>
>


.



Relevant Pages

  • Re: bye-bye holly hack...
    ... As far as I can see, there is a difference between the DOM and CSS Recommendations regarding what constitutes the "root of the document tree". ... The Document interface represents the entire HTML or XML ...
    (comp.infosystems.www.authoring.stylesheets)
  • searching recursively through directories
    ... I am writing some code to locate files in a given root ... Dim colFiles As Collection ... Set colFiles = New Collection ... Public Sub GetFiles(ByRef poLocatedFiles As Collection, ...
    (microsoft.public.vb.general.discussion)
  • RE: Shell prompt
    ... was visible that you was logged in as root. ... skeleton .bashrc did fix it for root? ... missing PS1 set as a normal user? ... [root@aabento html]# ...
    (Fedora)
  • Re: references
    ... I am working with a JSP page that resides in folder "X" in the root, ... and includes a .HTML page from the root folder itself. ... The my problem is that when it references the HTML file from the root ...
    (comp.lang.java.help)
  • Re: Includes in libraries
    ... Regarding this well-known quote, often attributed to Tim Tyler's famous ... > I don't want lots of includes in my HTML. ... > ...in an HTML file some distance from the root. ...
    (comp.lang.php)