How can I stop Visual Studio spoiling my valid XHTML ?

B

Brian Lowe

I'm using Visual Studio to build ASP.Net pages and I'm trying to be
standards compliant by using XHTML.

In my page I create valid XHTML such as:
<ul>
<li>first list item</li>
<li>second list item<br />
includes a line break</li>
</ul>

When I switch between design and HTML modes Visual Studio screws up my XHTML
to turn it in to:
<ul>
<li>
first list item
<li>
second list item<br>
includes a line break
</li>
</ul>
Any <LI> except the last is missing its closing tag.
Any 'self closing' tag such as IMG, BR, HR is stripped of it closure.

I've searched all over but can't find any instruction or setting that might
control this kind of thing.

The obvious place would be the !DOCTYPE setting, but manually inserting the
correct DOCTYPE and a URL for the DTD doesn't help.

Less obvious would be the 'target browser' setting but none of the options
offered geerates XHTML.

So. Can anyone tell me how to set up VS2003 (EA) so that I can have the IDE
build ASP.Net pages that are
valid XHTML instead of HTML?

Brian Lowe
---------@
 
G

Guest

In VS go to Tools - Options - HTML/XML - Format
At the top top you have "Apply Automatic Formatting" section.
Uncheck the tow checkboxes, so the VS doesn't format your HTML.

Hope that helps!
Regards,
Kostadin Kostov
 
B

Brian Lowe

Thanks.

This is a good answer to my question. It does exactly what I asked.

My question should have been "How can I get Visual Studio to tidy up my
XHTML without making it invalid?"

I'd like to be able to have VS reformat the XHTML in the same way that it
does HTML, but for it to retain the necessary closures on 'self closing'
elements like <br /> and <img /> and on tags like <li> where the </li> is
optional in HTML but mandatory in XHTML.

At least until I find something to do that I can just stop VS reformatting
anything.
 
T

Tampa.NET Koder

Unfortunately, this feature...it really is a bug..did not ship with vs2003.
It will always mess with your markup no matter what you do. They plan on
resolving this in the next release of Visual Studio
 
G

Guest

If you know what you are doing enough to write xhtml on your own I recommend
just giving design view the boot. I haven't used design view in about 2
years now. Also, the doctype that visual studio sticks in there is invalid
and causes your page to render in quirks mode.
 
B

Brian Lowe

Tampa.NET Koder said:
Unfortunately, this feature...it really is a bug..did not ship with
vs2003. It will always mess with your markup no matter what you do. They
plan on resolving this in the next release of Visual Studio

All that hype about it being extensible and being able to add your own
XSD/DTD to add your own intellisense etc, and yet the combined wisdom of
Microsoft isn't able to create the required custom extension that enables
XHTML in the IDE?

Roll on 2005 (Oh, 2005 is here, so where's VS2005?)

Brian Lowe
---------@
 
B

Brian Lowe

I guess design view isn't offering me much of a benefit anyway, so setting
it aside is the way to go.

Thanks also for the tip about the generated doctype.

Brian Lowe
---------@
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top