我有以下代码:
<%@ 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>
答案 0 :(得分:2)
试试这个
HtmlMeta metaKey = new HtmlMeta();
meta.Name = "Refresh";
meta.Content = _refresh_In_Seconds + "; url=whatEver.aspx";
Page.Header.Controls.Add(metaKey);
答案 1 :(得分:0)
你必须使用HtmlMeta的HttpEquiv属性,所以代替:
metaKey.Name = "Refresh";
放:
metaKey.HttpEquiv = "Refresh";