I'm not sure what the logic is behind the covers. I tried a few examples to see if I could identify the pattern. If you dynamically add texboxes, labels, etc.. you also see them in the same line while viewing source. Tables, rows, and cells end up with
line breaks, as do divs and others. Maybe it's just containers, who knows...
I think you're right in that you can't control it with out extra effort. If you had some reason you really wanted your html formatted, you could always add a literal control. for example:
//My first CSS
HtmlLink myCSS = new HtmlLink();
myCSS.Href = "~/somecss1.css";
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(myCSS);
//Here comes my second
myCSS = new HtmlLink();
myCSS.Href = "~/somecss2.css";
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(myCSS);
Member
2 Points
30 Posts
Page.Header.Controls.Add question (anyway to make output pretty?)
Jan 29, 2009 11:53 PM|agthr|LINK
Hello.
I think ASP.NET has many many great fetures and is indeed very productive, but I must say outputs are not very pretty (ASP.NET HTML that is)
Say I want to add something to the header section of my page, maybe 2 links to CSS and a JavaScript.
It's all easy and fancy, but when I look at the output HTML, its all in oneline!
Are there ANYWAY to make it so the output is like
Or its just the way it is? ThanksContributor
2015 Points
405 Posts
Re: Page.Header.Controls.Add question (anyway to make output pretty?)
Jan 30, 2009 03:42 AM|Rick Matthys|LINK
I'm not sure what the logic is behind the covers. I tried a few examples to see if I could identify the pattern. If you dynamically add texboxes, labels, etc.. you also see them in the same line while viewing source. Tables, rows, and cells end up with line breaks, as do divs and others. Maybe it's just containers, who knows...
I think you're right in that you can't control it with out extra effort. If you had some reason you really wanted your html formatted, you could always add a literal control. for example:
//My first CSS
HtmlLink myCSS = new HtmlLink();
myCSS.Href = "~/somecss1.css";
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(myCSS);
Page.Header.Controls.Add(new LiteralControl("\r\n"));
//Here comes my second
myCSS = new HtmlLink();
myCSS.Href = "~/somecss2.css";
myCSS.Attributes.Add("rel", "stylesheet");
myCSS.Attributes.Add("type", "text/css");
Page.Header.Controls.Add(myCSS);
Page.Header.Controls.Add(new LiteralControl("\r\n"));
~Rick
Disclaimer: Just my opinion. Not my employer or anyone else....
Member
2 Points
30 Posts
Re: Page.Header.Controls.Add question (anyway to make output pretty?)
Jan 30, 2009 03:59 AM|agthr|LINK
Thank you for your reply!
This would work just fine! Thank you so much.