Solved

How to add a dynamic facebook like button in ASP

Posted on 2010-09-23
13
973 Views
Last Modified: 2012-05-10
Hi there, I've got a DVD/Blu-Ray review web site and want to add Facebook's "Like" button on all my reviews.  Now I can easily do this the static way, but I'm using ASP and a MYSQL database and would like to try and find a way to automate it.  But...I've no idea how.

I was wondering if anyone had taken a crack at this and if so, what the code might be?
0
Comment
Question by:freezilla
  • 8
  • 4
13 Comments
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33748819
I think this is all that you need.
This is what I use on my site(s) and it works like a charm...

Good Luck with the site, I have a similar review site as well that I really need to get back to work on and make it look better, as I threw it together to quickly at the time. Would love to see yours, you can contact me through my email on my profile.

Here is the code that I use.

Information for Facebook SHARE
Change the information that I have marked as CHANGE.....

The <%=CHANGE_TITLE%> this would be for your title of your DVD item.
The other 2 CHANGE are your site name, you can customize this however you need to get it to work for you.

Information for Facebook LIKE

Change the www.yourdomain.com/Main.asp , to your actual domain.com name, that is all that needs to be changed in the LIKE.

Good luck and look forward to see you site if you decide, maybe we can throw some idea's to each other...

Have a good one.
Carrzkiss
Facebook SHARE



<a href="javascript:void(window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.toString()),'ptm','height=450,width=440').focus())" title="Share With Facebook - CHANGE - <%=CHANGE_TITLE%>"><img src="graph/share/facebook.gif" border="0" alt="CHANGE - Share With Facebook" /></a>



Facebook LIKE



<iframe src="http://www.facebook.com/plugins/like.php?href=<%=EncodeURL("http://www.yourdomain.com/Main.asp?"&(Request.QueryString))%>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:35px;" allowTransparency="true"></iframe>

Open in new window

0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33748840
One last thing.
Save the codes above to a page called: facebook.asp
The in your main page, add it to the page, maybe at the top of a bar or whereever.
<!--#include file="facebook.asp"-->

It only needs to be put in one place to work across your entire site.

Good Luck
Carrzkiss
0
 

Author Comment

by:freezilla
ID: 33749358
I'll give it a shot and see if it works for me.  I've actually had the site since 1999, but I'm just now incorporating Facebook functionality in there.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33749446
It should work out of the box.
Good Luck
Carrzkiss
0
 
LVL 16

Expert Comment

by:golfDoctor
ID: 33749521
For dynamic site, you simply add the URL to the embed tag:

<iframe src=""http://www.facebook.com/plugins/like.php?href=YOUR_URL&layout=button_count&show_faces=false&width=80&action=like&font=lucida+grande&colorscheme=light"" scrolling=""no"" frameborder=""0"" allowTransparency=""true"" style=""border:none; overflow:hidden; width:80px; height:21px;margin-top:5px;""></iframe>
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33749883
golfDoctor, did you not see that I already provided this to him?
http:#a33748819
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:freezilla
ID: 33753812
Hmmm, ok I seem to be a bit lost here.  I’ll try to explain it a bit better.  I’ve got one ASP page that handles all of my reviews and it’s cleverly called “reviews.asp”.  This page pulls all the information from the database and displays it in a query string (which is my URL).  So all I do is go into my admin, enter a review and it spits out the review by the ID number.

For example: www.sitename.com/reviews.asp?reviewid=1234 

So taking this into consideration, how would I use the above code to dynamically generate this link?  Or will I need to add another field to my database called “Facebook” and then manually enter in something when doing a new review?
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33754570
The code the I provided for you, I have put in a single place on my page.
It works across 10,000+ pages that will grow to be over 1,000,000+ pages by the summer.

Please, follow the instructions that I gave you on what needs to be edited, and it will work for you without any problems, as it works for me.
0
 
LVL 30

Accepted Solution

by:
Wayne Barron earned 500 total points
ID: 33755539
Let me better explain this to you.
Break down the code.

http://www.yourdomain.com/Main.asp?"&(Request.QueryString))%>

In the above URL, change the    domain.com   to yours
The Main.asp change this to your page.  review.asp
The ?"&(Request.QueryString))%>
Leave this alone, this will grab your Querystring which is ?reviewid=1234

Now, that is all that needs to be done to this for it to work on your site.

So yours string will look like this.
(Changing to fit your example that you provided above)

http://www.sitename.com/reviews.asp?"&(Request.QueryString))%>

And the code below will work in your page.
Just change the    sitename.com to your actual domain name.
That is all the needs to be changed for it to work.

Good Luck
Carrzkiss
Facebook LIKE



<iframe src="http://www.facebook.com/plugins/like.php?href=<%=EncodeURL("http://www.sitename.com/reviews.asp?"&(Request.QueryString))%>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:35px;" allowTransparency="true"></iframe>

Open in new window

0
 

Author Comment

by:freezilla
ID: 33756544
Hmmm, this didn’t work.  Ah well, not that big of a deal, it wasn’t really a necessity for the site.  I appreciate all the help.
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33757609
what did not work?
This is what I use, and it works on my site(s)
0
 

Author Comment

by:freezilla
ID: 33771376
I finally did figure this out.  Here's the code I'm using if it matters...

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.sitename.com%2Freviews.asp%3Freviewid%3D<% =strreviewid %>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="false"></iframe>
<fb:like href="http://www.sitename.com/reviews.asp?reviewid=<% =strreviewid %>" show_faces="false"></fb:like><br />
0
 
LVL 30

Expert Comment

by:Wayne Barron
ID: 33773095
Give me a little hint.
Always put your code in the code view, so it is better readable.

And glad that you got it figured out.
Take Care and have a good one.
Carrzkiss
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.sitename.com%2Freviews.asp%3Freviewid%3D<%=strreviewid%>&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=like&amp;colorscheme=dark&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="false"></iframe>

<fb:like href="http://www.sitename.com/reviews.asp?reviewid=<%=strreviewid%>" show_faces="false"></fb:like><br />

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now