Print Page | Close Window

External Links page

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=11879
Printed Date: 29 March 2026 at 12:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: External Links page
Posted By: huwnet
Subject: External Links page
Date Posted: 20 September 2004 at 3:22pm
As you all know I am not very good with programming. 

However I need to make an external link page.

e.g website www.microsoft.com

link on page = www.huwnet.org.uk/external.aspx.....microsoft.com

page read=

external link blah blah blah click to continue to microsoft.com



Replies:
Posted By: Mart
Date Posted: 20 September 2004 at 3:38pm
so something like this:

Dim Url As String = Request.QueryString("URL")
hl1.NavigateUrl = Url
...

To go to this link please click <asp:Hyperlink id="hl1" runat="server">here</asp:Hyperlink>?


Posted By: huwnet
Date Posted: 22 September 2004 at 2:09pm
So the path is www.blah.com/blah.aspx?url=blah.com


Posted By: Mart
Date Posted: 22 September 2004 at 2:34pm
yep


Posted By: huwnet
Date Posted: 23 September 2004 at 11:51am
Does asp.net use <% ?


Posted By: huwnet
Date Posted: 23 September 2004 at 11:52am
and <!--


Posted By: huwnet
Date Posted: 23 September 2004 at 12:01pm
Here is the code I am using, please tell me what is wrong:

<% Dim Url As String = Request.QueryString("URL")
hl1.NavigateURL = URL %>

<html>
<head>
<title>Huwnet - Redirect</title>
</head>
<body>
<asp:Hyperlink id="hl1" runat="server">Go to site</asp:Hyperlink>?
</body>
</html>


Posted By: Mart
Date Posted: 23 September 2004 at 12:10pm
First off you need a page declareation (the very first line):

<%@ Page Language = "VB" %>

ASP.NET can use <% %> but theres little point using it as it has been replaced by <script> tags (for inline code). Try this code instead (p.s. next time post the error)

<%@ Page Language = "VB" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
hl1.NavigateUrl = Server.URLEncode(Request.Querystring("URL"))
End Sub
</script>

<html>
<head>
<title>Huwnet - Redirect</title>
</head>
<body>
<form runat="server" id="form1">
<asp:Hyperlink id="hl1" runat="server">Go to site</asp:Hyperlink>
</form>
</body>
</html>



Posted By: huwnet
Date Posted: 23 September 2004 at 12:15pm
Works except the link comes out as: http://test.huwnet.org.uk/http%3a%2f%2fwww.microsoft.com


Posted By: Mart
Date Posted: 23 September 2004 at 12:20pm
scrap the URL encode, change

hl1.NavigateUrl = Server.URLEncode(Request.Querystring("URL"))

to

hl1.NavigateUrl = Request.Querystring("URL")


Posted By: huwnet
Date Posted: 25 September 2004 at 1:49pm
Thanks that worked well.

Is there any way the script could be changed slightly so that instead of being a hyperlink it could be a page include

e.g http://www.huwnet.org.uk/redirect.aspx?page=article1.html

code=

include=page


Posted By: Mart
Date Posted: 25 September 2004 at 3:09pm
I don't know why you would want to do that but this should work (presuming the file is on the same server as the web server)


<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Dim FilePath As String = Server.MapPath(Request.QueryString("page"))

    If Path.GetExtension(FilePath).ToLower = ".html" or _
    Path.GetExtension(FilePath).ToLower = ".htm" Then

    Dim sr As StreamReader

    Try
    sr = New StreamReader(FilePath)
    Catch ex As Exception
    litArticle.Text = "<b>Error:</b> " & ex.Message
    Exit Sub
    End Try

    litArticle.Text = sr.ReadToEnd()

    sr.Close()
    End If
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <h1>View Article
        </h1>
        <h1><font size="3">Here is the article you requested:</font>
        </h1>
        <p>
         &nbs p;  <asp:Literal id="litArticle" runat="server"></asp:Literal>
        </p>
    </form>
</body>
</html>



Posted By: huwnet
Date Posted: 26 September 2004 at 8:48am
Using that code  i get:

View Article

Here is the article you requested:

&nbs p;




Posted By: Mart
Date Posted: 26 September 2004 at 10:26am
You have to add the ?page=artcle.html to the end of the URL


Posted By: huwnet
Date Posted: 26 September 2004 at 12:26pm
I did. See http://www.huwnet.org.uk/redirect.aspx?page=top.asp


Posted By: huwnet
Date Posted: 26 September 2004 at 12:28pm
UPDATE: With html http://www.huwnet.org.uk/redirect.aspx?page=donate.html

It works but you still get &nbs p;
With asp it doesn't work at all.


Posted By: Mart
Date Posted: 26 September 2004 at 12:33pm
Just delete the &nbs p; before the literal control - WWF must have put it in for some reason. That script will only display htm and html files so that nobody can peek at the source code of your asp  and aspx pages


Posted By: huwnet
Date Posted: 26 September 2004 at 1:08pm
Ok, is there any way to get it to process the asp/aspx and then display it?


Posted By: huwnet
Date Posted: 26 September 2004 at 1:13pm
Without the &nbs p; it just displays:

View Article

Here is the article you requested:




Posted By: Mart
Date Posted: 26 September 2004 at 1:31pm
Try it with a html page again, it will not work with ASP


Posted By: Diep-Vriezer
Date Posted: 26 September 2004 at 4:47pm
Or use an iframe. But why don't you create somesort of web user control? Would be a lot easier.

-------------
Gone..


Posted By: Mart
Date Posted: 26 September 2004 at 5:02pm
I agree, or store the articles in a database


Posted By: huwnet
Date Posted: 28 September 2004 at 1:52pm
Originally posted by Diep-Vriezer Diep-Vriezer wrote:

Or use an iframe. But why don't you create somesort of web user control? Would be a lot easier.


I am learning xml, access etc and then it will run from a database.

Mart that script works great but is there any way of changing it so that it will also process asp/asp.net?


Posted By: Mart
Date Posted: 28 September 2004 at 3:29pm
It won't actually process ASP or ASP.NET, but it will display the source... I made it so only htm and html can be displayed so nobody can go peeking at your source code by redirect.aspx?page=default.asp revealing all your source code...


And before you ask - no you cannot get it to process ASP, you can get it to process ASP.NET but its rather complicated.. If you want to do that take a look at the cassini source project over at www.asp.net but I think it will go straight over your head


Posted By: Diep-Vriezer
Date Posted: 28 September 2004 at 5:50pm

Indeed. You are only adding like 2 lines of text above it..



-------------
Gone..


Posted By: huwnet
Date Posted: 01 October 2004 at 1:05pm
Originally posted by Mart Mart wrote:

I agree, or store the articles in a database


are the any basic tutorials on how to do this?


Posted By: Mart
Date Posted: 01 October 2004 at 2:16pm
yes



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net