Skip to content

Instantly share code, notes, and snippets.

@WengerK
Created November 21, 2012 11:00
Show Gist options
  • Save WengerK/4124320 to your computer and use it in GitHub Desktop.
Save WengerK/4124320 to your computer and use it in GitHub Desktop.
Dynamic change title & meta page on ASP
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Title="MyTitle" Inherits="ASP1._Default" MasterPageFile="~/MasterPage.Master" %>
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ASP1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Hello World";
// Programmatically add a <meta> element to the Header
HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content = "master page,asp.net,tutorial";
Page.Header.Controls.Add(keywords);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment