2

我有以下代码:

<%@ page title="בחירת מועמדי הליכוד" language="C#"
masterpagefile="~/Site.master" autoeventwireup="true" %> <asp:Content
ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content> <asp:Content ID="BodyContent" runat="server"
ContentPlaceHolderID="MainContent"> <center> <div class="endMsg"> תודה
רבה על השתתפותך ! </div> </center> </asp:Content>

我想添加元标记:

<meta http-equiv="Refresh" content="60; url=http://your.new/url/here" />

如何编写被解释为该元标记的代码?

编辑:根据评论,我编写了以下代码:

public partial class Thanks : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int _refresh_In_Seconds = 5;
        HtmlMeta metaKey = new HtmlMeta();
        metaKey.Name = "Refresh";
        metaKey.Content = _refresh_In_Seconds + "; url=Default.aspx";
        Page.Header.Controls.Add(metaKey);  
    }


}

重定向不起作用。谁能解释为什么?

编辑2:

这是该问题的另一种解决方案:

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<meta http-equiv="Refresh" content="10; URL=Default.aspx">
</asp:Content>
4

2 回答 2

2

尝试这个

             HtmlMeta metaKey = new HtmlMeta();
             meta.Name = "Refresh";
             meta.Content = _refresh_In_Seconds + "; url=whatEver.aspx"; 
             Page.Header.Controls.Add(metaKey);
于 2012-05-23T14:57:46.440 回答
0

您必须使用 HtmlMeta 的 HttpEquiv 属性,而不是:

metaKey.Name = "Refresh";

放:

metaKey.HttpEquiv = "Refresh";
于 2012-05-23T20:22:36.740 回答