Reputation: 1384
I have a block of C# code that I want to write some HTML within:
if ( someCondition ) {
%><span>its_important_my_span_has_no_spaces_around_it</span><%
}
int x = 0;
// ...
But in Visual Studio 2010, after the <%, I hit Enter and I get
if ( someCondition ) {
%><span>its_important_my_span_has_no_spaces_around_it</span><%
}
int x = 0;
// ...
It even re-formats this way automatically (e.g., when I type the semicolon).
I keep poking around the Options > Text Editor area in HTML and C# to figure out what to turn on or off but I'm at a loss.
What am I doing wrong?
Edit:
If I highlight that first } and re-type it, it puts it in the right place.
Upvotes: 0
Views: 416
Reputation: 4043
This is always going to be a PITA. Simple way to deal with it though. Immediately after you hit Enter (or any action that auto formats) press Alt+Backspace and move on.
Alternatively, you can go to your Text Editor options and remove all auto formatting for C#, but i don't think you'll want to do that because that will apply to all of your code-behind files.
Upvotes: 1