Controlling whitespace when using server-side evaluationhttp://forums.asp.net/t/1196335.aspx/1?Controlling+whitespace+when+using+server+side+evaluationThu, 20 Dec 2007 00:35:10 -050011963352068867http://forums.asp.net/p/1196335/2068867.aspx/1?Controlling+whitespace+when+using+server+side+evaluationControlling whitespace when using server-side evaluation <p>&nbsp;Currently, if there is a line of code in a ViewPage, for example:</p> <pre class="prettyprint">&lt;% foreach (Product p in ViewData) { %&gt;</pre>&nbsp;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?&nbsp; 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.<br> &nbsp; 2007-12-19T18:44:16-05:002069042http://forums.asp.net/p/1196335/2069042.aspx/1?Re+Controlling+whitespace+when+using+server+side+evaluationRe: Controlling whitespace when using server-side evaluation <p>&nbsp;Nice call, Brail for Monorail has the ability to have &lt;%... -%&gt;&nbsp; The - before the closing script tag tells Brail to squash the new line.&nbsp; It makes for some very nice html.</p> <p>I<a href="/p/1194407/2068967.aspx#2068967">f we are talking about extending the asp.net compiler for MVC</a>, I would throw this into the mix.&nbsp;</p> 2007-12-19T20:23:16-05:002069385http://forums.asp.net/p/1196335/2069385.aspx/1?Re+Controlling+whitespace+when+using+server+side+evaluationRe: Controlling whitespace when using server-side evaluation <p>&nbsp;The trick is placement of the &lt;% %&gt; tags which should be where the HTML &amp; whitespace should stop and not where the code starts...<br> </p> <p>e.g. if you wanted all the options on one line but the code over many;&nbsp;</p> <pre class="prettyprint">&lt;select id=&quot;something&quot;&gt;&lt;% foreach(Product p in ViewData) { %&gt;&lt;option value=&quot;&lt;%=HttpUtility.HtmlAttributeEncode(p.Code)%&gt;&quot;&gt;&lt;%=HttpUtility.HtmlEncode(p.Description)%&gt;&lt;/option&gt;&lt;% } %&gt;</pre> <p>[)amien&nbsp;</p> <p><br> &nbsp;</p> 2007-12-20T00:35:10-05:00