titi
titi

Reputation: 1035

Facebook Like Button in ASP.NET MVC C#

I've created my website that used to show the products; when the user click on the product, it will show the product detail of each item: I want to put the Facebook Like Button inside them.

I tried using http://developers.facebook.com/docs/reference/plugins/like/. This is the url that I tried to put: http://ff/Products/ProductSpec/ (it is in my local), but actually each product have different parameter string due to its ID.

<iframe src="http://www.facebook.com/plugins/like.php?
href=http://www.example.com/Prod/Spec/1115?dep=82&cat=243&tab=2"
scrolling="no" frameborder="0"
style="border:none; width:450px; height:80px"></iframe>

But the URL that shared on my wall in facebook just only "http://www.example.com/Prod/Spec/1115?dep=82" NOT "http://www.example.com/Prod/Spec/1115?dep=82&cat=243&tab=2"

Could anyone tell me how to have Facebook Like Button in ASP .NET MVC website with C# please?

Upvotes: 0

Views: 5416

Answers (2)

Kath
Kath

Reputation: 1854

You could go to the Facebook site dedicated to this button, generate the code and copy it into your layout page (or into view page, as you wish). The process is absolutely the same as for any other technology.

Okay, the task is pretty the same. You just need to put the generated code into the csthml and change slightly the url. For example you generate the following code

<div class="fb-like" data-href="http://www.mysite.com" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-action="recommend" data-font="lucida grande"></div>

you could create some variable like:

    @{
string page url = @Url.Action("ProductSpec", "Products", new {id= item.Id})
}

and then replace the url in you link:

    <div class="fb-like" data-href=@url data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-action="recommend" data-font="lucida grande"></div

Upvotes: 1

Aviral Kumar
Aviral Kumar

Reputation: 824

You can create an image button of the like button first and then ..associate a label with it with the incremented integer value. If u want to to store it in database u can also do that.

Upvotes: 2

Related Questions