I guess you can't just add the meta tags to the Page.Controls collection but have to use
Page.Header.Controls.Add(meta1);
instead.
Alternatively you could also create a literal control in the header section on the master page where you can write the description to. The above solution is more elegant though. :)
I'm going to have to recant, what I stated above did get rid of the exception thrown however it didn't add the meta element to the page either. So I'm going to try to use the public property method using your link above.
Attempting to add Meta Element to page Dynamically getting the following Error:
I have a usercontrol that I'm using to insert the following to a content page:
<meta name="description" content="Our Lovely Page" />
Server Error in '/' Application.
The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
I've tried Page_Init and override CreateChildeControls events... Any help would be greatly appreciated.
Hi Kevon,
have a look at this:
http://forums.asp.net/p/1122258/1755180.aspx
I guess you can't just add the meta tags to the Page.Controls collection but have to use
instead.
Alternatively you could also create a literal control in the header section on the master page where you can write the description to. The above solution is more elegant though. :)
Hope that helps,
Sascha
I'll let you know the results...
I also have to use the Page_PreInit Event
Cool, thanks for letting me know!
Sascha,
I'm going to have to recant, what I stated above did get rid of the exception thrown however it didn't add the meta element to the page either. So I'm going to try to use the public property method using your link above.
is working on a reply...