Is there a way to add source-structured inputs dynamically to html through c#?
-
Is there a way to add source-structured inputs dynamically to html through c#? I'm adding inputs (HtmlGenericControls) dynamically to an ASP.NET. If I have 10 inputs I'd like to "view source" and see them neatly stacked on top of each other instead of rendered back-to-back in a big block. I've tried adding the following literal controls after each input in the loop but it doesn't seem to do anything: LiteralControl newLine = (new LiteralControl(((char)10).ToString())); LiteralControl carriageReturn = (new LiteralControl(((char)13).ToString())); Do you know if there's a way to do what I'm trying to do?
-
Is there a way to add source-structured inputs dynamically to html through c#? I'm adding inputs (HtmlGenericControls) dynamically to an ASP.NET. If I have 10 inputs I'd like to "view source" and see them neatly stacked on top of each other instead of rendered back-to-back in a big block. I've tried adding the following literal controls after each input in the loop but it doesn't seem to do anything: LiteralControl newLine = (new LiteralControl(((char)10).ToString())); LiteralControl carriageReturn = (new LiteralControl(((char)13).ToString())); Do you know if there's a way to do what I'm trying to do?
What does it matter what the "view source" view looks like? How it is rendered is what is important.
I know the language. I've read a book. - _Madmatt
-
Is there a way to add source-structured inputs dynamically to html through c#? I'm adding inputs (HtmlGenericControls) dynamically to an ASP.NET. If I have 10 inputs I'd like to "view source" and see them neatly stacked on top of each other instead of rendered back-to-back in a big block. I've tried adding the following literal controls after each input in the loop but it doesn't seem to do anything: LiteralControl newLine = (new LiteralControl(((char)10).ToString())); LiteralControl carriageReturn = (new LiteralControl(((char)13).ToString())); Do you know if there's a way to do what I'm trying to do?
Well first of all i have to agree with Mark Nischalke, really how the HTML is formatted is irrelevant it only matters how the browser is rendering it. Having said that, I noticed in your code sample that you are creating the controls but not actually adding it to a place holder (which is how you should be dynamically adding controls to a web form) so maybe try adding your controls to a place holder and the HTML should render based on the order they were added to the place holder.
If at first you don't succeed ... post it on The Code Project and Pray.