views:

39

answers:

1

The question is similar to this one, but I cannot figure how to make the formatting also apply to the ASP.NET server side tag <% %>

Like the related question, a block like this one

Good

<ul id="menu">
    <li><%: Html.ActionLink("Home", "Index", "Home")%></li>
    <li><%: Html.ActionLink("About", "About", "Home")%></li>
</ul>

Will get formatted into

Bad

<ul id="menu">
    <li>
        <%: Html.ActionLink("Home", "Index", "Home")%></li>
    <li>
        <%: Html.ActionLink("About", "About", "Home")%></li>
</ul>

I want to prevent Visual Studio from changing the formatting concerning asp.net server tag <% %>.

Does someone know?

Nota: This is not a question about minifying the html output. This is for design time only. Its more of an annoyance than anything else.

+1  A: 

Try Tools -> Options -> Tree View Text Editor node -> HTML -> Format -> Tag Specific Options button -> Default Settings -> Client tag does not support contents -> In the Line breaks dropdown, select None.

The <% ... %> is seen by the editor as just another tag, in this case a Client tag that doesn't support contents.

Daniel Dyson
The `li` setting is already at Before and After. It work well if the content is not a `<% %>`. As soon as I embed code in my page, the format setting for all elements fails.
Pierre-Alain Vigeant
See updated post.
Daniel Dyson
Figured it out, the tag is `%:` and not a single `%`.
Pierre-Alain Vigeant