开发者

Adding elements to the Header of the masterpage from contentplaceholder in .NET

开发者 https://www.devze.com 2023-01-06 05:04 出处:网络
I\'m with a problem The scenario is the follow: After submitting a form the user recieves one message says OK, and is redirected to another page after 2seconds.

I'm with a problem

The scenario is the follow:

After submitting a form the user recieves one message says OK, and is redirected to another page after 2seconds.

The problem is, when insert is sucefully, i add to the header of the masterpage a HtmlMeta element, but when i'm inserting from the conte开发者_如何学运维ntplaceholder, i recieved a followed error:

" The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). "

any solution guys?

apreciated

Edit:

public static void MetaRedirect(Page p, string url) { HtmlMeta meta = new HtmlMeta();

        meta.Content = "2;url=" + url;
        meta.HttpEquiv = "refresh";

        p.Header.Controls.Add(meta);
    }


Two things spring to mind. The first is potentially overkill but could be useful for other things as well: add a new content area in the master page in the header that you can then use to add any header elements you want. Alternatively you can probably just add a placeholder into your header for much the same effect.

0

精彩评论

暂无评论...
验证码 换一张
取 消