Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 844249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:15:22+00:00 2026-05-15T06:15:22+00:00

MVC is formatting my code horribly, and I was wondering if you can turn

  • 0

MVC is formatting my code horribly, and I was wondering if you can turn it off? I feel the answer is no, but I was hoping VS 2010 had built in a setting…

Here’s what its formatting as:

                  <% if (org.UserKey.HasValue)
{ %>

                        <%= org.Reference(i => i.UserReference).Email%>

                  <% }
else
{ %>

                        <%= org.UserEmail%>

                  <% } %>

I want the beginning brackets on the same line as the if and the else…

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:15:23+00:00Added an answer on May 15, 2026 at 6:15 am

    You can indeed set this.

    In Visual Studio, go to Tools -> Options.

    In the treeview on the left, navigate to Text Editor -> C# -> Formatting -> New Lines. You can uncheck the checkbox for “Place open brace on new line for control blocks.”

    Unfortunately, this will also change it for all of your *.cs files as well.

    Another option to clean it up a bit is to change your “<%=” blocks to Response.Write. That way, you can avoid having so many opening and closing <% tags, as follows:

     <% if (org.UserKey.HasValue)
        {
            Response.Write(org.Reference(i => i.UserReference).Email);
        }
        else
        {
            Response.Write(org.UserEmail);
        } %>
    

    As one final side note, if you’re using .NET 4.0, you should use <%: instead of <%= from now on. That Html-encodes your output so you can easily injection attacks. It is the same thing as Response.Write(HttpUtility.HtmlEncode(expression)).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

MVC 2 comes with built-in support of Model validation but how do I do
Is there any way to disable ReSharper Web Form/MVC (.aspx) Code Formatting on Brace
MVC 2 I'm trying to post to an MVC action using jQuery, but I'm
Our mvc application sets the response status code to 401 and sets TrySkipIisCustomErrors to
I've got a problem with the formatting of inline code blocks within the VS2010
I am just learning MVC and I've created a form but I would like
I had a similar problem a few months ago, but that was easily solved
I'm trying to learn ASPNET MVC. I've built a DbModel starting from DB structure
Are there any way to turn of the autoformatting of C# code that is
I'm a newbie about ASP.NET MVC 3, but I have a simple question. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.