Reputation: 423
I am using a hyperlink in my code to re-direct the user to an article. At the moment the link is hard coded with a standard anchor
with a href.
I've created a condition in my code behind
:
If MyLists.MyListId = 1 Then
MyLists.MyListRecommendation = "Largest Number of Businesses"
MyLists.MyListSummary = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
MyLists.MyListUrl = "/how-to-become-a-developer/"
END
At the moment I am attempting to use a literal link how i've been using previously and this is where I am getting stuck.
<a href="<asp:Literal ID="MyListUrl" runat="server" /> ">VIEW ARTICLE</a>
Currently, when clicking on the hyperlink text the page is not re-directed to any url. It is re-directed to /=
I am trying to get the hyperlink to re-direct to my MyListUrl
Upvotes: 0
Views: 620
Reputation: 15091
Since you using asp anyway why not use an asp:HyperLink
?
In your .aspx file...
<asp:HyperLink ID="MyLink2" runat="server">View Article</asp:HyperLink>
I had to guess what your class might look like.
In your code behind...
Public Class Links
Public Property MyListId As Integer
Public Property MyListRecommendation As String
Public Property MyListSummary As String
Public Property MyListUrl As String
End Class
Dim MyLists As New Links()
MyLists.MyListId = 1
If MyLists.MyListId = 1 Then
MyLists.MyListRecommendation = "Largest Number of Businesses"
MyLists.MyListSummary = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
MyLists.MyListUrl = "http://www.microsoft.com"
End If
MyLink2.NavigateUrl = MyLists.MyListUrl
To work directly with an anchor tag.
In the .aspx file...
<a id="Beans" runat="server">View Another Article</a>
Then in code behind just replace the .NavigateUrl
line with
Beans.HRef = MyLists.MyListUrl
Upvotes: 1