none
HtmlMeta 为什么写出来的东西会在CSS连接后面 RRS feed

  • 问题

  • 例如MSDN的例子:
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
      protected void Page_Load(object sender, EventArgs e)
      {
        // Create two instances of an HtmlMeta control.
        HtmlMeta hm1 = new HtmlMeta();
        HtmlMeta hm2 = new HtmlMeta();    
    
        // Get a reference to the page header element.
        HtmlHead head = (HtmlHead)Page.Header;
    
        // Define an HTML <meta> element that is useful for search engines.
        hm1.Name = "keywords";
        hm1.Content = "words that describe your web page";
        head.Controls.Add(hm1);
    
        // Define an HTML <meta> element with a Scheme attribute.
        hm2.Name = "date";
        hm2.Content = DateTime.Now.ToString("yyyy-MM-dd");
        hm2.Scheme = "YYYY-MM-DD";
        head.Controls.Add(hm2);
    
      }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>HtmlMeta Example</title>
    这地方如果加入CSS连接的话,程序写出来的关键字就会在CSS连接后面。但是我想再后台写关键字出来想把它放在head CSS连接前面。要怎么改

    </head> <body> <form id="form1" runat="server"> <div> View the HTML source code of the page to see the two HTML meta elements added. </div> </form> </body> </html>

    除了在前台<%=xxx%>
    高人指点下。

    2009年12月15日 15:34

答案

  •   HtmlMeta hm1 = new HtmlMeta();
                HtmlMeta hm2 = new HtmlMeta();

                // Get a reference to the page header element.
                HtmlHead head = (HtmlHead)Page.Header;

                // Define an HTML <meta> element that is useful for search engines.
                hm1.Name = "keywords";
                hm1.Content = "words that describe your web page";
                head.Controls.AddAt(1,hm1);

                // Define an HTML <meta> element with a Scheme attribute.
                hm2.Name = "date";
                hm2.Content = DateTime.Now.ToString("yyyy-MM-dd");
                hm2.Scheme = "YYYY-MM-DD";
                head.Controls.AddAt(2,hm2);

    • 已标记为答案 Xhp 2009年12月16日 1:48
    2009年12月15日 16:04

全部回复

  •   HtmlMeta hm1 = new HtmlMeta();
                HtmlMeta hm2 = new HtmlMeta();

                // Get a reference to the page header element.
                HtmlHead head = (HtmlHead)Page.Header;

                // Define an HTML <meta> element that is useful for search engines.
                hm1.Name = "keywords";
                hm1.Content = "words that describe your web page";
                head.Controls.AddAt(1,hm1);

                // Define an HTML <meta> element with a Scheme attribute.
                hm2.Name = "date";
                hm2.Content = DateTime.Now.ToString("yyyy-MM-dd");
                hm2.Scheme = "YYYY-MM-DD";
                head.Controls.AddAt(2,hm2);

    • 已标记为答案 Xhp 2009年12月16日 1:48
    2009年12月15日 16:04
  • Thank you very much
    2009年12月16日 1:48