Susan
Susan

Reputation: 1832

ASP.Net C# <asp:Hyperlink> tag not routing as expected

Below is the code that I'm using in my aspx page

            <asp:HyperLink ID="detaldfjk" runat="server">
                <asp:Label ID="detWebAddr" runat="server" Text=""></asp:Label>
            </asp:HyperLink>

Here is the code in my code-behind page:

        detaldfjk.NavigateUrl = restDetails[0].REST_WEBSITE;
        detWebAddr.Text = restDetails[0].REST_WEBSITE;

The data in the REST_WEBSITE holds,for instance, www.AnotherSite.com. Instead of routing to the expected site, it is routing as follows:

http://localhost:50281/www.AnotherSite.com

Thanks in advance!

Upvotes: 0

Views: 332

Answers (1)

Arnold Zokas
Arnold Zokas

Reputation: 8560

You are not passing a fully qualified url, so the browser appends it to your current url.

You need to add "http://" at the beginning of you url.

detaldfjk.NavigateUrl = "http://" + restDetails[0].REST_WEBSITE;

Upvotes: 2

Related Questions