How to add a Facebook "Like" or "Recommended" button in Silverlight and

Posted by in ASP.NET category on for Intermediate level | Points: 250 | Views : 25389 red flag
Rating: 5 out of 5  
 1 vote(s)

You ran to my article thinking that you will definitely do this in silverlight. Well it is practically not possible because you have to use iframes to do that and iframes cannot be used in xaml. But I will show you how can do it for your silverlight application not necessarily injecting it in your xaml.


In this article i explained how you can add a facebook like button in Silverlight and in a normal application.

Using the code

Luckly we are not going to write code, it will be just html code only.


I was listening to the radio the day before yesterday,Radio 702(in South Africa) interviewed a very intelligent man who is a CEO of one of  the biggest companies in South Africa or rather in the world. He said something interesting. He said. “If today my first day at work starting my career, i would have never been a ceo of my company.Because the market we had years ago was not as competitive as the one we have today. The market today is very competative and its unpredictable, you are not sure if you will be in business on the next six months and if your marketing strategy and leadership in your business is not uptoscratch your business might not survice even if you render the best service.”

This is a powerfull statement. What did It tell me?  From the statement I learned that if you don’t advertise correctly , your business will never be known , even if you have good products or services. 

Back to the Subject

Now let us get back to the subject of the article. i came I across a site that I cant mention. That site had a  Facebook “like Button” as depicted below

Normally when you click on that "like" or "Recommended" button , every friend you have will see that on your wall and they might want to see what is it that you like and this is a very good advertising strategy. The good part of this, is that another friend might like it too and it might lead to a long chain,especially if you have friends that have more than a thousand friends on facebook.  To add this feuture to your website , you will easly go to the following facebok site to generate the code

Now on the “URL to Like” enter your full website url

And the layout can be standard and you can choose to show a face of the person who will be accessing the site and who is connecting to facebook or who is a member of facebook. The width of the button can be controled in the width.The “Verb to Display” you can either choose “Like” or “recommeded” and the font can be changed too , but I like it as is. Click the get code button. The Following modal will appear as depicted below

, copy the code. Let us inspect the code. Mine look's like this


<iframe src=";layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:60px"></iframe>


Well as I said above you can inject the iframe into your xaml, what you need to do, is to compile your silverlight application and when you are ready to deploy it ,you need to do one small thing. In the html page or aspx page that you will use to host your silverlight app just above or below it depends on your design , you can add the iframe as is from the generated code as depicted below
Silverlight Example


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">





<div id="silverlightControlHost">

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

<param name="source" value=""/>

<param name="onError" value="onSilverlightError" />

<param name="background" value="white" />

<param name="minRuntimeVersion" value="3.0.40818.0" />

<param name="autoUpgrade" value="true" />

<a href="" style="text-decoration:none">

<img src="" alt="Get Microsoft Silverlight" style="border-style:none"/>



<iframe src=";layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:500px; height:60px"></iframe>




Now if you want to do this with your application is simple because you have a freedom of adding it anywhere you want. After your code look’s like mine  run the page and it should look like this


Now I had a Silverlight  app, as you can see my Silverlight application shows a hand without fingers , but its not part of the topic. So if I click on the “Recommend” or “Like” the small text area will appear so that someone can enter comments as depicted below

If you click on the post button , your message will be posted on your wall as depicted below


Your website or the service your business render's can be popular if you can do this.  Thank you again for visiting Dotnetfunda

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Vuyiswa Maseko
Member Level: NotApplicable
Member Status: Member,MVP,Administrator
Member Since: 7/6/2008 11:50:44 PM
Country: South Africa
Thank you for posting at Dotnetfunda [Administrator]
Vuyiswa Junius Maseko is a Founder of Vimalsoft (Pty) Ltd ( and a forum moderator at www.DotnetFunda. Vuyiswa has been developing for 16 years now. his major strength are C# 1.1,2.0,3.0,3.5,4.0,4.5 and and sql and his interest were in, c#, Silverlight,wpf,wcf, wwf and now his interests are in Kinect for Windows,Unity 3D. He has been using .net since the beta version of it. Vuyiswa believes that Kinect and Hololen is the next generation of computing.Thanks to people like Chris Maunder (codeproject), Colin Angus Mackay (codeproject), Dave Kreskowiak (Codeproject), Sheo Narayan (.Netfunda),Rajesh Kumar(Microsoft) They have made vuyiswa what he is today.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)