Use HtmlHead control to set the page title and meta tags. : Header « HTML Controls « ASP.NET Tutorial






<%@ Page Language="C#" AutoEventWireup="true"%>

<script runat="server"> 
    void buttonSet_Click(object sender, EventArgs e)
    {
        Header.Title = Msg.Text;
    }

    void buttonMetaSet_Click(object sender, EventArgs e)
    {
        string format = "<meta http-equiv='refresh' content='{0}' />";
        LiteralControl equiv;
        equiv = new LiteralControl(String.Format(format, Content.Text));
        ((Control)Header).Controls.Add(equiv);
        Response.Write("This text will disappear in 3 seconds...");
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Testing HtmlHead</title>
</head>
<body>
    <div id="pageContent">
        <form runat="server" id="MainForm">
            <h1>Set the title</h1>
            <asp:textbox runat="server" id="Msg" text="This is the title"  />
            <asp:button runat="server" id="buttonSet" text="Set" 
                        onclick="buttonSet_Click" />
            <hr />
            <h1>Set HTTP-EQUIV tag</h1>
            <asp:textbox runat="server" id="Content" text="3" />
            <asp:button runat="server" id="buttonMetaSet" text="Set" 
                        onclick="buttonMetaSet_Click" />
            <hr />
        </form>
    </div>
</body>
</html>








4.6.Header
4.6.1.Use HtmlHead control to set the page title and meta tags.
4.6.2.Use HtmlHead control to set the add page transition effects when viewed through Internet Explorer.