How do I create dynamic content (has to be easy!)
-
I’m missing something (I’m experienced with C, C++ but not with C#, ASP.NET)... I want to dynamically create a control/random HTML. Do I have to do it with, for example,
HtmlTable table1 = new HtmlTable(); table1.Attributes.Add(“border”, “0”); table1.Attributes.Add(“align”, “center”); div1.controls.Add(table1);
etc. or can I pass ‘<table border=”0” align=”center”>...</table>’ to something and have it render it? Rog -- modified at 14:41 Friday 20th January, 2006 -
I’m missing something (I’m experienced with C, C++ but not with C#, ASP.NET)... I want to dynamically create a control/random HTML. Do I have to do it with, for example,
HtmlTable table1 = new HtmlTable(); table1.Attributes.Add(“border”, “0”); table1.Attributes.Add(“align”, “center”); div1.controls.Add(table1);
etc. or can I pass ‘<table border=”0” align=”center”>...</table>’ to something and have it render it? Rog -- modified at 14:41 Friday 20th January, 2006You don't have to render it if it's already html code. You put it on the page. Use for an example a placeholder: <asp:Placeholder id="Arthur" runat="server"/> Add a literal control containing the html code:
Arthur.Controls.Add(new LiteralControl("<table ... > ... </table>"));
--- b { font-weight: normal; } -
You don't have to render it if it's already html code. You put it on the page. Use for an example a placeholder: <asp:Placeholder id="Arthur" runat="server"/> Add a literal control containing the html code:
Arthur.Controls.Add(new LiteralControl("<table ... > ... </table>"));
--- b { font-weight: normal; }Excellent, thank you. I already have an 'Arthur' to hang things off. So, to do the dynamic bits, I can just adjust the string or use Arthur.FindControl("x") afterwards to adjust it. It's these things like not knowing about LiteralControl which are the 'things you don't know you don't know' that make forums like this so worthwhile! Thanks again. Rog