Social bookmarks code for .NET

For a recent project, built with asp.net and Visual Studio 2008, I needed to create buttons for social bookmarks - Digg, Delicious, etc. It is pretty straightforward actually so I thought I’d share the code.

For my project I used Master Pages and vb, so for C#, you can convert it here.

social bookmarking

Master Page code

Put this is in your page load:

Partial Class yourclass
    Inherits System
.Web.UI.MasterPage
    
Public strURL As String
    
Public strTitle As String

    
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs
Handles Me.Load
        strURL 
Page.Request.Url.AbsoluteUri
        strTitle 
Page.Title
        Session
("PageTitle") = <strong>strTitle</strong>
        
Session("PageURL") = <strong>strURL</strong>
    
End Sub

End 
Class 

HTML

Because I’m nice, here are the URL structures for various social networking sites.

<ul id="share">
<
li id="email"><a href="<%=Page.ResolveUrl("~/email-to.aspx")%>" title="Email this to a friend">Email this to a friend </a></li>
<
li id="delicious"><a href="http://del.icio.us/post?url=<%=strURL%>&amp;title=<%=strTitle %>">Del.icio.us</a></li>
<
li id="digg"><a href="http://digg.com/submit?url=<%=strURL%>&amp;title=<%=strTitle %>">Digg</a></li>
<
li id="facebook"><a href="http://www.facebook.com/sharer.php?u<%=strURL%>">Facebook</a></li>
<
li id="furl"><a href="http://furl.net/storeIt.jsp?t=<%=strTitle%>&amp;u=<%=strURL%>">Furl</a></li>
<
li id="google"><a href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=<%=strURL%>&amp;title=<%=strTitle %>">Google Bookmarks</a></li>
<
li id="linkedin"><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=<%=strURL%>&amp;title=<%=strTitle %>">LinkedIn</a></li>
<
li id="myspace"><a href="http://www.myspace.com/Modules/PostTo/Pages/?u=<%=strURL%>">Myspace</a></li>
<
li id="reddit"><a href="http://reddit.com/submit?url=<%=strURL%>&amp;title=<%=strTitle %>">Reddit</a></li>
<
li id="stumbleupon"><a href="http://www.stumbleupon.com/submit?url=<%=strURL%>&amp;title=<%=strTitle %>">StumbleUpon</a></li>
<
li id="windowslive"><a href="https://favorites.live.com/quickadd.aspx?url=<%=strURL%>&amp;title=<%=strTitle %>">Windows Live</a></li>
</
ul

And that is that.

You could use something like Add This but this gives you more control over the html and output.

And for icons (if you want them), I suggest Social Media Mini Iconpack.

There may be other ways to do this with .net, so let me know.

5 comments so far

  1. Alfred

    Pure International Calls. Buy Cheap Calling Cards and Phone Cards.

  2. Malissa

    Save Your money with InterCalls. International calling cards and phone cards.

  3. toll free numbers

    Hey, I must say that I have also been on the lookout for the social bookmarks code for the dot Net Framework. After all, we all have our work and responsibilities and it is my duty as a student to make a project for my college. I should say that this project is built with Visual Studio 2010 as well as ASP. NET, which I am sure quite conveys what I want here! I really am glad that I have come across the right area for the codes!

Don't just sit there, join in!

Commenting is not available in this weblog entry.

Preview