Self closing Html Generic Control?
Posted
by Chalkey
on Stack Overflow
See other posts from Stack Overflow
or by Chalkey
Published on 2009-11-10T13:40:25Z
Indexed on
2010/03/18
12:11 UTC
Read the original article
Hit count: 488
I am writing a bit of code to add a link tag to the head tag in the code behind... i.e.
HtmlGenericControl css = new HtmlGenericControl("link");
css.Attributes["rel"] = "Stylesheet";
css.Attributes["type"] = "text/css";
css.Attributes["href"] = String.Format("/Assets/CSS/{0}", cssFile);
to try and achieve something like...
<link rel="Stylesheet" type="text/css" href="/CSS/Blah.css" />
I am using the HtmlGenericControl to achieve this... the issue I am having is that the control ultimatly gets rendered as...
<link rel="Stylesheet" type="text/css" href="/CSS/Blah.css"></link>
I cant seem to find what I am missing to not render the additional </link>
, I assumed it should be a property on the object.
Am I missing something or is this just not possible with this control?
Thanks
© Stack Overflow or respective owner