Make sure you keep track of the selected Item between clicks so you can make sure to set the selected item of the datalist however.
Main Topics
Browse All TopicsI have a list of hyperlinks in a VB.NET Web application. I want to high-light the hyperlink in the list that was clicked last (i.e. the current hyperlink). How do I make the current hyperlink bold, or possibly a different color? Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Off the top of my head, something like this might work-
First, define the hyperlinks as serverobjects by adding a runat and id tag, i.e.:
<a href="somelink" runat="server" id="link1">My Link</a>
Then in the codebehind, add a global variable to the form:
Private LastLink As String
And handle the link_clicked event
Private Sub Link_Clicked(ByVal sender As Object, ByVal e As System.EventArgs) Handles Link1.Clicked
Dim a As HtmlAnchor = CType(sender,HtmlAnchor)
LastLink = a.ID
End Sub
Then in the Page_Load() event, you parse the document for that link and highlight it...
For Each c As Control In Me.Controls
if TypeOf(c) Is HtmlAnchor Then
c.ForeColor = Color.Blue
End If
Next
Just an idea...
Business Accounts
Answer for Membership
by: DrewKjellPosted on 2005-07-18 at 13:25:44ID: 14469913
If you are using a datalist set the selectedItem background color. Then in the datalist define a hyperlink for the <selectedItem> template.
r="dimgray " >
I.E:
<asp:DataList id="MyList" SelectedItemStyle-BackColo
<ItemTemplate>
<asp:HyperLink id="HyperLink1" Text='myText' NavigateUrl='myLink' runat="server" />
</ItemTemplate>
<SelectedItemTemplate>
<asp:HyperLink cssclass="MenuSelected" id="HyperLink2" Text='myText' NavigateUrl='myLink' runat="server" />
</SelectedItemTemplate>
</asp:DataList>