Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET. MVC 2 C#: So much whitespace
    text
    copied!<p>There a section of my code that is a mix between <code>&lt;% %&gt;</code> statements and HTML ... the view source is horrible. There is so much whitespace it makes me choke with disgust.</p> <p>Is there anything I can do about this?</p> <pre><code>&lt;!-- START Content --&gt; &lt;div class="divFilterWrap"&gt; &lt;img src="/Content/Images/filterMainCuisineHeader.gif" /&gt; &lt;ul&gt; &lt;% int count = 1; %&gt; &lt;% foreach (var filter in Model.Filter) { %&gt; &lt;% if (filter.GroupOrder == count) { } else { %&gt; &lt;% count++; %&gt; &lt;/ul&gt; &lt;% switch (filter.GroupLabel) { %&gt; &lt;% case "Main Cuisine": %&gt; &lt;img src="/Content/Images/filterMainCuisineHeader.gif" width="175" height="30" /&gt; &lt;% break; %&gt; &lt;% case "Dining Style": %&gt; &lt;img src="/Content/Images/filterDiningStyleHeader.gif" width="175" height="30" /&gt; &lt;% break; %&gt; &lt;% case "Price Range": %&gt; &lt;img src="/Content/Images/filterPriceRangeHeader.gif" width="175" height="30" /&gt; &lt;% break; %&gt; &lt;% } %&gt; &lt;ul&gt; &lt;% } %&gt; &lt;% if (filter.TagCount &gt; 0) { %&gt; &lt;% if (filter.TagChecked == 1) { %&gt; &lt;li class="checked"&gt;&lt;%: filter.TagLabel %&gt; (&lt;%: filter.TagCount %&gt;) &lt;span class="closeImage"&gt;&lt;img src="/Content/Images/filterButtonClose.gif" /&gt;&lt;/span&gt;&lt;/li&gt; &lt;% } else { %&gt; &lt;li&gt;&lt;%: filter.TagLabel %&gt; (&lt;%: filter.TagCount %&gt;)&lt;/li&gt; &lt;% } %&gt; &lt;% } %&gt; &lt;% } %&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- END Content --&gt; </code></pre> <p>Where the C# code sits, that space is reserved when viewing source. And here is what it looks like:</p> <pre><code>&lt;!-- START Content --&gt; &lt;div class="divFilterWrap"&gt; &lt;img src="/Content/Images/filterMainCuisineHeader.gif" /&gt; &lt;ul&gt; &lt;li&gt;Coffee / Tea House (1)&lt;/li&gt; &lt;/ul&gt; &lt;img src="/Content/Images/filterDiningStyleHeader.gif" width="175" height="30" /&gt; &lt;ul&gt; &lt;li&gt;Casual Dining (1)&lt;/li&gt; &lt;/ul&gt; &lt;img src="/Content/Images/filterPriceRangeHeader.gif" width="175" height="30" /&gt; &lt;ul&gt; &lt;li&gt;$8 to $15 (1)&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- END Content --&gt; </code></pre> <p>GROSS!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload