![]() |
|
|
|||||||
![]() |
ASP Net - How can I stop Visual Studio spoiling my valid XHTML ? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 ---------@ Brian Lowe |
|
|
|
|
#2 |
|
Posts: n/a
|
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 "Brian Lowe" wrote: > 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 > ---------@ > > > |
|
|
|
#3 |
|
Posts: n/a
|
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. "Kostadin Kostov" <> wrote in message news:FD4384D9-B4D8-4ECF-82A8-... > 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 > > "Brian Lowe" wrote: > >> 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 >> ---------@ >> >> >> |
|
|
|
#4 |
|
Posts: n/a
|
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 "Brian Lowe" <> wrote in message news:... > 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. > > > > > "Kostadin Kostov" <> wrote in > message news:FD4384D9-B4D8-4ECF-82A8-... >> 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 >> >> "Brian Lowe" wrote: >> >>> 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 >>> ---------@ >>> >>> >>> > > |
|
|
|
#5 |
|
Posts: n/a
|
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. |
|
|
|
#6 |
|
Posts: n/a
|
"Tampa.NET Koder" <> wrote in message news:... > 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 ---------@ |
|
|
|
#7 |
|
Posts: n/a
|
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 ---------@ "Scott Simons" <Scott.Simons.At.MealMagic.Com.Remove.This> wrote in message news > 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. |
|