Forum Moderators: open

Message Too Old, No Replies

Return current URL Page

how to post current page info into a link

         

adventurewagen

6:42 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



I've almost given up on this. I've run across some examples such as using Request.ServerVariables("script_name"), but nothing works.

Here is what I have:

page1.aspx
------------------------------------------------------
//This script displays my "home" div by default

<script language="VB" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
if len(request.querystring("sub"))>0 then
Select case(request.querystring("sub"))
case "overview"
overview.visible=true
hideoverview.visible=false
case "1"
sub1.visible=true
hide1.visible=false
case "2"
sub2.visible=true
hide2.visible=false
end select
else
home.visible=true
hidehome.visible=false
end if
end sub
</script>

//Here are my divisions written up in my page
//I have 4 divisions, but only 2 with content right now

<div id="home" runat="server" visible="false">
<p>Some Content for my home division of an item</p>
</div>
<div id="overview" runat="server" visible="false">
<p>Different content for my overview section</p>
</div>
<div id="sub1" runat="server" visible="false"></div>
<div id="sub2" runat="server" visible="false"></div>

//Then I have my sidebar with links to each division

<asp:label id="hidehome" runat="server" text="<a href='/page1.aspx'>Home</a>" />

<asp:label id="hideoverview" runat="server" text="<a href='/page1.aspx?sub=overview'>Overview</a>" />

<asp:label id="hide1" runat="server" text="" />
<asp:label id="hide2" runat="server" text="" />

------------------------------------------------------

Problem is, each link is then hard coded to whatever page Im on. I have about 100 pages to develop, each of which has the same "home" and "overview" section. It would be nice to return the current page (whatever page that might be) in place of "page1.aspx". Then as I create each page I don't need to include and edit every single link on each page.

Somebody already said to try:<a href="<%=request("URL")%>">Link</a> which seems close to what I want but just doesn't work?

Any ideas would be greatly appreciated.

mrMister

7:34 pm on Aug 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Function fullURL() As String
Dim strProtocol, strHost, strPort, strUrl, strQueryString As String

strProtocol = Request.ServerVariables("HTTPS")
strPort = Request.ServerVariables("SERVER_PORT")
strHost = Request.ServerVariables("SERVER_NAME")
strUrl = Request.ServerVariables("URL")
strQuerystring = Request.ServerVariables("QUERY_STRING")

If strProtocol = "off" Then
strProtocol = "http://"
Else
strProtocol = "https://"
End If

If strPort <> "80" Then
strPort = ":" & strPort
Else
strPort = ""
End If

If strQueryString.length > 0 Then
strQueryString = "?" & strQuerystring
End If

Return strProtocol & strHost & strPort & strUrl & strQueryString
End Function

Example usage:

Response.write(fullURL)