Wesley Skeen
Wesley Skeen

Reputation: 8285

Custom pinterest button

I am trying to add a pinterest button to a control. I am trying to add the href in the code behind but it does not seem to be working.

so far i have

pinterestButton.Attributes.Add("href", "http://pinterest.com/pin/create/button/?url=" + productLink + "&media=" + imageLink);

The pinterest window opens up but there no data in it.

Can anyone give me a hand?

Thanks

Upvotes: 0

Views: 1090

Answers (2)

mng
mng

Reputation: 50

Im not sure what exactly sure what you're looking for your code to do...but paste this code in the place of the url of the pages you want to pin from. Should act as a pin it button.

javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());

Upvotes: 0

Mike Kibbel
Mike Kibbel

Reputation: 1971

It looks like you need to URI-encode the query string parameters, i.e.

"http://pinterest.com/pin/create/button/?url=" + productLink + "&media=" + imageLink

should be:

"http://pinterest.com/pin/create/button/?url=" + HttpUtility.UrlEncode(productLink) + "&media=" + HttpUtility.UrlEncode(imageLink)

I'm not an ASP/C# programmer, but a quick lookup shows that this is the correct method for URI-encoding.

Upvotes: 1

Related Questions