Reputation: 11469
I have a property in my .cs file basically
public string MyURL
{
get { return _myUrl; }
set { _myURL = value; }
}
This property gets the value as a string ad it would something like this www.shipco.com
.
The issue I am having is when i putting it in the page as an anchor with target blank it gives it as a location in the website like http://mywebsite/www.shipco.com
This is how I am setting it on the page:
<div>
<strong>URL :</strong>
<a href="<%=MyURL%>" target="_blank"><%=MyURL%></a>
</div>
I would appreciate any help as I am learning and not sure how to achieve this.
Upvotes: 0
Views: 71
Reputation: 499212
Basics of fully qualified URLs and relative URLs in the browser:
<a href="www.shipco.com" target="_blank">www.shipco.com</a>
The above means, go to the current URL, only replace the current page path with the href
. You will see that the source of the page is exactly what you expect it to be. The browser interprets it as a relative location to the current page - it doesn't "know" it is a different website.
You need to output the http://
as well:
<a href="http://<%=MyURL%>" target="_blank"><%=MyURL%></a>
Perhaps this About.com article will shed some light.
Upvotes: 4