Eranga Wijethunga
Eranga Wijethunga

Reputation: 215

Dynamically change Facebook share thumbnail in ASP .Net

I used Facebook like button in ASP .Net my web site master page and when sharing page link in Facebook. I want to change the thumbnail attach with link to each pages, I get image url back end of my asp website and assign to variable and when I'm trying to bind it to front end as below it doesn't get actual value

<link rel="image_src" type="image/jpeg" href=" <% = ImgLink %>"/>

(ImgLink is dynamic variable I got from my back end of code ) at least it doesn't suggest in visual studio.

Upvotes: 1

Views: 1825

Answers (2)

Ajay jha
Ajay jha

Reputation: 11

LitFacebook.Text = "<a name=\"fb_share\" type=\"button\" share_url =\"http://kidstrail.inoday.co.in/\"></a>" +
                   "<script " +
                   "src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" " +
                   "type=\"text/javascript\"></script>";

On Design Page, Take a Literal control:

<div style="float:left; height:18px; margin-left:3px; overflow:hidden;"><asp:Literal ID="LitFacebook" runat="server" ></asp:Literal> </div>

Upvotes: 1

Adrian Iftode
Adrian Iftode

Reputation: 15663

Try

<asp:PlaceHolder runat="server">
    <link rel="image_src" type="image/jpeg" <%= "href='" + ImgLink + "'"%>/>
</asp:Placeholder>

Here is a detailed explanation why this is working.

Upvotes: 1

Related Questions