I have the following c# code in my control's RenderContents method. How can I add the style/class that is in external css file?
output.AddAttribute(HtmlTextWriterAttribute.Border, "0");
output.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
output.RenderBeginTag(HtmlTextWriterTag.Table);
output.RenderBeginTag(HtmlTextWriterTag.Tbody);
output.RenderBeginTag(HtmlTextWriterTag.Tr);
//Here -> Need to add some style from external stylesheet.css file
output.RenderBeginTag(HtmlTextWriterTag.Td);
rblLoadSelection.RenderControl(output);
output.RenderEndTag(); //Td
output.RenderEndTag(); //Tr
output.RenderEndTag(); //Tbody
output.RenderEndTag(); //Table
You shouldn't reference an external stylesheet between a
td
andtr
. The best place to put it is in thehead
tag of your document.Based on your comments, if you just need to add a class to
td
, do this: