ASP.NET Tutorial/HTML Controls/Header

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Use HtmlHead control to set the add page transition effects when viewed through Internet Explorer.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <meta http-equiv="Page-Enter" content="progid:DXImageTransform.Microsoft.Fade(duration=.5)" />
    <meta http-equiv="Page-Exit" content="progid:DXImageTransform.Microsoft.Fade(duration=.5)" />
    <title>Transition Effects</title>
</head>
<body>
    <div id="pageContent">
        <form id="form1" runat="server">
            <h1>This is sample page with special transition effects</h1>
            <h2><a href="head.aspx">Visit another page and then come back here</a></h2>
        </form>
    </div>
</body>
</html>


Use HtmlHead control to set the page title and meta tags.

<%@ 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>