Currently, if there is a line of code in a ViewPage, for example:
<% foreach (Product p in ViewData) { %>
When evaluated, a blank line is emitted to the resulting HTML. Is there a way to control when/if these blank lines are emitted into the HTML? I like to have my code formatted with a decent amount of breaks, but the resultant HTML is not what I would
like to see.
Nice call, Brail for Monorail has the ability to have <%... -%> The - before the closing script tag tells Brail to squash the new line. It makes for some very nice html.
Dugald
Member
444 Points
85 Posts
Controlling whitespace when using server-side evaluation
Dec 19, 2007 06:44 PM|LINK
Currently, if there is a line of code in a ViewPage, for example:
<% foreach (Product p in ViewData) { %>When evaluated, a blank line is emitted to the resulting HTML. Is there a way to control when/if these blank lines are emitted into the HTML? I like to have my code formatted with a decent amount of breaks, but the resultant HTML is not what I would like to see.abombss
Member
575 Points
164 Posts
Re: Controlling whitespace when using server-side evaluation
Dec 19, 2007 08:23 PM|LINK
Nice call, Brail for Monorail has the ability to have <%... -%> The - before the closing script tag tells Brail to squash the new line. It makes for some very nice html.
If we are talking about extending the asp.net compiler for MVC, I would throw this into the mix.
MVC suggestion
damieng
Member
38 Points
16 Posts
Re: Controlling whitespace when using server-side evaluation
Dec 20, 2007 12:35 AM|LINK
The trick is placement of the <% %> tags which should be where the HTML & whitespace should stop and not where the code starts...
e.g. if you wanted all the options on one line but the code over many;
<select id="something"><% foreach(Product p in ViewData) { %><option value="<%=HttpUtility.HtmlAttributeEncode(p.Code)%>"><%=HttpUtility.HtmlEncode(p.Description)%></option><% } %>[)amien