Add Meta Tag on ASP.Net Page Load event

header run server meta tag Dynamically add meta description , meta keywords and change page title on each web page without any database , first step set your master page header set to run on server as show in picture.Next on web page load event add meta as shown in snippet

add meta tag on page load eventCode is executed and web page is populated with meta tags. Changing page header information run time helps search engines to categorize your web page.

Download

Example Source Snippets -

namespace : System.Web.UI.HtmlControls

Web page load event


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public partial class code_aspnet_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "Orem ipsum dolor sit amet consectet";

        // Set meta tag description
        HtmlMeta htmlMetaDescription = new HtmlMeta();
        htmlMetaDescription.Name = "description";
        htmlMetaDescription.Content = "Curabitur purus sem, malesuada eu luctus eget, suscipit sed turpis";
        Header.Controls.Add(htmlMetaDescription);

        // Set meta tag keywords
        HtmlMeta htmlMetaKeywords = new HtmlMeta();
        htmlMetaKeywords.Name = "keywords";
        htmlMetaKeywords.Content = "orem, ipsum, dolor, sit amet";
        Header.Controls.Add(htmlMetaKeywords);
    }
}

                    

smartsnipps.ecomparefiles.com © 2019, All Rights Reserved | Disclaimer: smartsnipps.eCompareFiles.com is free to use any code snippets without guarantee