Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Preserving hyperlink style settings by session

I was working on an ASP.NET site that wasn't Community Server yesterday (yeah, wild eh?), and was asked to change the colors of a potentially lengthy list of document links so that users could click on a link, view a document, then return to the list and readily determine which document links they had previously viewed.

Easy, A:Visited, but here was the catch.  It could only be for that session.  The list links had to appear virginal on the next visit.

Okay, how about turning off Response Cache.


<%
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
%>


That didn't work on my client's server.  I need to check into that when I can.  It worked on my office network, but not where we needed it to work.

Then I went into hack mode and thought "unique links...unique session."  The A:Visited style settings are applied to unique hyperlink addresses.  Add a SessionID to the url!

 

<asp:TemplateColumn>
    <ItemTemplate>
        <span class="doclink"><a href='<%#  DataBinder.Eval(Container.DataItem,"fileurl") +
            "?s=" + HttpContext.Current.Session.SessionID %>'
        target="_blank">
        <%#  DataBinder.Eval(Container.DataItem,"docname")%>
        </a></span>
    </ItemTemplate>
</asp:TemplateColumn>


My client told me people stopped by his office afterward saying "thank you, thank you, thank you!" for the functionality added by that simple hack. 

Comments (2) | Post RSS RSS comment feed

Posted on 1/17/2008 9:12:21 PM by Dave Burke
Categories: .NET

Related posts

Comments

Comments are closed

Copyright © 2008 Dave Burke Consulting  |  All Rights reserved.