Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to add a dynamic facebook like button in ASP

Posted on 2010-09-23
13
Medium Priority
?
997 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 31

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 31

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

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 31

Expert Comment

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

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 31

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 31

Accepted Solution

by:
Wayne Barron earned 2000 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 31

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 31

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
By following these Magento e-commerce development tips, you can increase your website's conversion and profitability. Read this post for more details.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

580 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