Add facebook share metatags to the head

Jan 22, 2014 at 2:45 PM
Edited Jan 22, 2014 at 2:45 PM

I'm trying to add Open Graph tags to the head. I want to set the title, description and image of the facebook share and I want to get the information from the server.

It gets filled up but the facebook crawler only sees the <% NewsTitle %> server tags and not the real title.

This is the fortyfingers control I want to use:
<fortyfingers:STYLEHELPER ID="STYLERHELPER5" AddToHead="<meta property='og:title' content='<% NewsTitle %>' />" runat="server" />
In the source code of my page this metatag is printed out:
<meta content="News title" property="og:title">
When I debug in the object debugger I get this in the object properties:
og:title    <% NewsTitle %>
I don't know if this has something to do with the stylehelper, but don't know where to ask it.

Can somebody help me with this?
Jan 22, 2014 at 4:54 PM
You cannot inject dynamic values that way in a skin object.
<% NewsTitle %> will not return anything, it will not even be processed by
I think you can use <%#NewsTitle %>, but in that case "NewsTitle" would have to resturn a value on databind of the .NET process.

Where does the NewsTitle come from in your case?
Jan 23, 2014 at 6:12 AM
NewsTitle is a property that is set in code behind. It just takes the title from a label on the news page.
public string NewsTitle
      get { return lblNewsTitle.Text; }
On page_load I now do DataBind() and use the <%#NewsTitle %> but now it shows
og:title    <%# NewsTitle %>
in the object properties when I debug the page.
Jan 23, 2014 at 7:51 AM
Ok, did you try generating the complete meta tag?


Then make the GetMeta function return the complete meta tag?
(I cannot test it myself right now)
Jan 23, 2014 at 7:59 AM
Not that didn't worked. I've temporarily solved it by adding a meta tag in code behind with HtmlMeta. When I have more time I will look again.

Thanks for your help!