Interpret a URL from a database

smaldark
02:28:13
We have an old classic ASP application that pulls a URL from an MSSQL database and we've had people recently ask about the URL, when clicked, going to a relative path. So, we'd have a URL of http://ourdomain.com/db_url and of course that link wouldn't exist.

I need to fix that output to the browser window, so that if a user clicks the URL, it takes them to the actual URL.

I could put "http://" in front of the db_url information, but then the URLs already being prefixed with "http://" would have "http://http://db_url" and that doesn't work.

I was looking at the Replace String function, but I cannot seem to implement it where I need it.

I get this to work:


<%
Dim string_var,string_find,string_replace
string_var= objProfile.FieldValue("db_url")
string_find= "http://"
string_replace=""
strURL = Response.Write Replace(string_var,string_find,string_replace)
%>


This returns the URL without the "http://", so now I need to implement it into the actual output in the web browser window.

We currently use:
<a href="http://<%=objProfile.TextField("db_url")%>" target=_new"><%=objProfile.TextField("db_url")%></a>

I need to figure out how to mix the Dim with the html output, so that I'm using the replaced URL where "db_url" exists.

Any help?
smo1234
02-28-2013
Inside your ASP code you should not keep string_replace="" ( as blank ) , use it like this
string_replace="http://ourdomain.com"

Now you will have your domain added inside the URL. Before keeping it inside the tag just check the format by printing it to screen.

Same variable you can place inside your tag and test.
Please Login to post your reply or start a new topic