Solved

How to add a dynamic facebook like button in ASP

Posted on 2010-09-23
13
980 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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 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 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Level out logo and increase size? 16 26
Html using "Or" in condition 3 27
Table style position to the left 8 26
StoredProcedure to JSON query faulty syntax 2 26
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime is disastrous for companies and can lead to major hits on a brand, reputation, an…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

733 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