C# & Adding Dynamic META Tags

Posted by Bry4n on Stack Overflow See other posts from Stack Overflow or by Bry4n
Published on 2010-04-30T02:31:54Z Indexed on 2010/04/30 2:37 UTC
Read the original article Hit count: 424

Filed under:
|
|
|

I have this code

 protected void Page_Load(object sender, EventArgs e)
{
    DataSet.DestinationsDataTable GetDestinations = (DataSet.DestinationsDataTable)dta.GetData();
    Page.Title = GetDestinations.Rows[0]["Meta_Title"].ToString();

    HtmlMeta hm = new HtmlMeta();
    HtmlHead head = (HtmlHead)Page.Header;
    hm.Name = GetDestinations.Rows[0]["Meta_Desc"].ToString();
    hm.Content = GetDestinations.Rows[0]["Meta_Key"].ToString();
    head.Controls.Add(hm);  
}

And it's returning this error (on a content page)

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

Thoughts?

© Stack Overflow or respective owner

Related posts about c#

Related posts about meta