Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:46:57+00:00 2026-06-12T00:46:57+00:00

I have three different like buttons on three different pages in my site. Is

  • 0

I have three different like buttons on three different pages in my site. Is there a way to dynamically create and assign these og tags based on what page the button is on?

Here is the code I am working with:

protected void Page_Load(object sender, EventArgs e)
{


    // ADD META INFORMATION TO HEADER
    HtmlHead head = (HtmlHead)Page.Header;


    // KEYWORDS
    HtmlMeta hm = new HtmlMeta();
    hm.Name = "keywords";
    hm.Content = this.metaKeywords;
    head.Controls.Add(hm);

    // DESCRIPTION
    hm = new HtmlMeta();
    hm.Name = "description";
    hm.Content = this.metaDescription;
    head.Controls.Add(hm);

    // ************************************************************************

    //      <meta property="og:title" content="Faces of Metastatic Breast Cancer (MBC) Video Wall" />
    //      <meta property="og:type" content="cause" />
    //      <meta property="og:image" content="http://www.facesofmbc.org/images/MBC_Logo.png"/>
    //      <meta property="og:url" content="http://bit.ly/rkRwzx" />
    //      <meta property="og:site_name" content="Faces of Metastatic Breast Cancer (MBC)" />
    //      <meta property="og:description" content="I just viewed the new Faces of Metastatic Breast Cancer (MBC) video wall. For each view, comment or share of the video wall during October, Genentech will donate $1 to MBC initiatives. Watch TODAY!" />
    //      <meta property="fb:admins" content="653936690"/>

    string ogTitle = "";
    string ogType = "";
    string ogImage = "";
    string ogUrl = "";
    string ogSiteName = "";
    string ogDescription = "";
    string ogAdmins = "";


    if (Page.Request.Path.Contains("videoWall.aspx"))
    {
        hm = new HtmlMeta();
        hm.Attributes.Add("property", "og:title");
        hm.Content = "TEST OG TITLE";
        head.Controls.Add(hm);

        hm = new HtmlMeta();
        hm.Name = "og:type";
        hm.Content = "TEST OG TYPE";
        head.Controls.Add(hm);
    }
    // ************************************************************************
}

I know it is wrong and that there appears to be different approaches, but I am just showing you what I was doing and the direction I was going. The commented out tags are just there as a guide to which ones I will need. Any help would be appreciated!

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:46:59+00:00Added an answer on June 12, 2026 at 12:46 am

    What if you turn your properties into an interface and then throw that interface onto the classes that use your control?

    You could create an interface that contains all of the properties you are trying to get…

    interface IFaceBookMeta
    {
        string ogTitle {get; set;}
        string ogType {get; set;}
        //...... and so on
    }
    

    Then apply that interface to the page that you want to host the control on.

    public partial class SomePageThatHasTheControl: System.Web.UI.Page, IFaceBookMeta
    

    Then, in that class, you can now explicitly set the properties of the interface

    this.ogTitle = "A Random Title";
    this.ogType = "A Type";
    

    Now, you go to your control’s code and do something like this:

    //This is the page that is hosting the control.
    IFaceBookMeta meta = (IFaceBookMeta)this.Page;
    
    hm = new HtmlMeta();
    hm.Attributes.Add("property", "og:title");
    hm.Content = meta.ogTitle;
    head.Controls.Add(hm);
    
    hm = new HtmlMeta();
    hm.Name = "og:type";
    hm.Content = meta.ogType;
    head.Controls.Add(hm);
    //.... and so on
    

    Doing it this way would prevent you from modifying the control’s code every time you added the control to another page. Instead, you just slap the interface on the page where you want the control, set the properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have three different tables like this table_1 Field 1: victories Field 2:
I have a form with three different dropdown menus, it looks like this: <FORM
I'm playing with a GWT/GAE project which will have three different pages, although it
I have a page having 3 buttons i need to add different beep like
I have three different List collections. How can I show them in one ListBox
I have three different configurations on my project, all three do not require all
I have three different development machines. Do I need three different iPhone Developer Program
My problem is that I have three different stock sizes for each product that
I have developed three different versions(as different projects) of an app(large,normal,small). How can I
I have built three different cells in my storyboard and hooked all the outlets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.