473,387 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VS2005 and DOCTYPE in Web Forms

I am porting an existing 2003 project to 2005. Yesterday I found that some
of my Java script did not want to work. After eventually examining the HTML
view of the new and old form for differences, I noticed the DOCTYPE lines
pretty close to the top of the forms in HTML view differ. I removed the line
in the new form and my Java script worked. Today I noticed that a SPAN on a
new form with the width property set to 100% displayed about 1/4 over the
page, so I thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line generated by
VS2005 is evil or a new standard, but it surely causes problems.
Nov 20 '05 #1
6 1459
Chris Botha wrote:
I am porting an existing 2003 project to 2005. Yesterday I found that
some of my Java script did not want to work. After eventually
examining the HTML view of the new and old form for differences, I
noticed the DOCTYPE lines pretty close to the top of the forms in
HTML view differ. I removed the line in the new form and my Java
script worked. Today I noticed that a SPAN on a new form with the
width property set to 100% displayed about 1/4 over the page, so I
thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line
generated by VS2005 is evil or a new standard, but it surely causes
problems.


What you experience is called "quirks" mode. See
http://www.quirksmode.org/css/quirksmode.html for more details.

Here's how IE 6 decides between quirks and standards compliant mode:

http://msdn.microsoft.com/library/de.../en-us/dnie60/
html/cssenhancements.asp

Unfortunately, Visual Studio .NET 2002 and 2003 both use a default
DOCTYPE in ASP.NET that *enables* quirks mode.
[Hony soit qui mal y pense ;-)]

What does all that mean for your HTML? If it requires quirks mode, it's
most likely broken...

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 20 '05 #2
The following JavaScript will allow the "width" style for spans to work in
all browsers, regardless of DOCTYPE:

<script type="text/javascript" >
var sps = document.getElementsByTagName("span");
for (var index = 0; index < sps.length; index++)
{
var sp = sps[index];
if (sp.className == "label")
{
var s = sp.style.width.substring(0, sp.style.width.indexOf("px"));
var i = (s - sp.offsetWidth) / 2;
if (sp.style.textAlign == "center")
{
sp.style.paddingLeft = i;
sp.style.paddingRight = i;
}
else if (sp.style.textAlign == "right")
sp.style.paddingLeft = i * 2;
else
sp.style.paddingRight = i * 2;
}
}
</script>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:xn****************@msnews.microsoft.com...
Chris Botha wrote:
I am porting an existing 2003 project to 2005. Yesterday I found that
some of my Java script did not want to work. After eventually
examining the HTML view of the new and old form for differences, I
noticed the DOCTYPE lines pretty close to the top of the forms in
HTML view differ. I removed the line in the new form and my Java
script worked. Today I noticed that a SPAN on a new form with the
width property set to 100% displayed about 1/4 over the page, so I
thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line
generated by VS2005 is evil or a new standard, but it surely causes
problems.


What you experience is called "quirks" mode. See
http://www.quirksmode.org/css/quirksmode.html for more details.

Here's how IE 6 decides between quirks and standards compliant mode:

http://msdn.microsoft.com/library/de.../en-us/dnie60/
html/cssenhancements.asp

Unfortunately, Visual Studio .NET 2002 and 2003 both use a default
DOCTYPE in ASP.NET that *enables* quirks mode.
[Hony soit qui mal y pense ;-)]

What does all that mean for your HTML? If it requires quirks mode, it's
most likely broken...

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 20 '05 #3
Hi Kevin, I should have mentioned that the span width is set on the style of
the span, thus:
<span style="WIDTH: 100%; .....>

So what I am saying is that Java script as well as normal HTML breaks with
the DOCTYPE settings used by VS2005.
The Java script that broke was (1) I've set a handler for the
document.onscroll and the event did not fire any more, and (2) on another
form I had something like theDiv.scrollIntoView().

Thanks in any case.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
The following JavaScript will allow the "width" style for spans to work in
all browsers, regardless of DOCTYPE:

<script type="text/javascript" >
var sps = document.getElementsByTagName("span");
for (var index = 0; index < sps.length; index++)
{
var sp = sps[index];
if (sp.className == "label")
{
var s = sp.style.width.substring(0, sp.style.width.indexOf("px"));
var i = (s - sp.offsetWidth) / 2;
if (sp.style.textAlign == "center")
{
sp.style.paddingLeft = i;
sp.style.paddingRight = i;
}
else if (sp.style.textAlign == "right")
sp.style.paddingLeft = i * 2;
else
sp.style.paddingRight = i * 2;
}
}
</script>

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:xn****************@msnews.microsoft.com...
Chris Botha wrote:
I am porting an existing 2003 project to 2005. Yesterday I found that
some of my Java script did not want to work. After eventually
examining the HTML view of the new and old form for differences, I
noticed the DOCTYPE lines pretty close to the top of the forms in
HTML view differ. I removed the line in the new form and my Java
script worked. Today I noticed that a SPAN on a new form with the
width property set to 100% displayed about 1/4 over the page, so I
thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line
generated by VS2005 is evil or a new standard, but it surely causes
problems.


What you experience is called "quirks" mode. See
http://www.quirksmode.org/css/quirksmode.html for more details.

Here's how IE 6 decides between quirks and standards compliant mode:

http://msdn.microsoft.com/library/de.../en-us/dnie60/
html/cssenhancements.asp

Unfortunately, Visual Studio .NET 2002 and 2003 both use a default
DOCTYPE in ASP.NET that *enables* quirks mode.
[Hony soit qui mal y pense ;-)]

What does all that mean for your HTML? If it requires quirks mode, it's
most likely broken...

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de


Nov 20 '05 #4
Hi Joerg, thanks for the links. That such a subtle thing can cause so many
problems (I debugged for quite a while before I stumbled upon it). When I
see a funny in a page now, first thing I do is to remove the DOCTYPE.
[Shame to him who thinks evil of it :-)]

Thanks.
"Joerg Jooss" <ne********@joergjooss.de> wrote in message
news:xn****************@msnews.microsoft.com...
Chris Botha wrote:
I am porting an existing 2003 project to 2005. Yesterday I found that
some of my Java script did not want to work. After eventually
examining the HTML view of the new and old form for differences, I
noticed the DOCTYPE lines pretty close to the top of the forms in
HTML view differ. I removed the line in the new form and my Java
script worked. Today I noticed that a SPAN on a new form with the
width property set to 100% displayed about 1/4 over the page, so I
thought let me give the DOCTYPE line a shot, I removed it and the
SPAN displays perfectly. So, I am not sure if the DOCTYPE line
generated by VS2005 is evil or a new standard, but it surely causes
problems.


What you experience is called "quirks" mode. See
http://www.quirksmode.org/css/quirksmode.html for more details.

Here's how IE 6 decides between quirks and standards compliant mode:

http://msdn.microsoft.com/library/de.../en-us/dnie60/
html/cssenhancements.asp

Unfortunately, Visual Studio .NET 2002 and 2003 both use a default
DOCTYPE in ASP.NET that *enables* quirks mode.
[Hony soit qui mal y pense ;-)]

What does all that mean for your HTML? If it requires quirks mode, it's
most likely broken...

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de

Nov 20 '05 #5
<snip />

So what's the general consensus when building VS2005 2.0 applications? Any
Target Schema suggestions? The Master is currently using this...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >

<%= Clinton Gallagher
Nov 20 '05 #6
clintonG wrote:
<snip />

So what's the general consensus when building VS2005 2.0
applications? Any Target Schema suggestions? The Master is currently
using this...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml" >

<%= Clinton Gallagher


It really depends on your both clients (browsers) and clients (the guys
giving you money).

Personally, I'd stay from quirks mode whenever possible, especially if
supporting multiple browser types is a requirement. One quirk that
works fine in one browser may cause disaster in another browser.

If accessibility is a requirement, you most likely have to render
standards compliant HTML -- many screenreaders don't work too well with
quirks mode HTML, and laws or regulations regarding accessibility may
simply prescribe that only standards compliant HTML is to be used for
certain types of web sites (government agencies etc.).

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: clintonG | last post by:
VS2005 2.0 Beta 2 noting I've posted (to no avail so far) to the somewhat deadzone at news://microsoft.public.vsnet.ide and am getting ants in my pants for some discussion about this issue. ...
3
by: Darrin | last post by:
Hello, I see that VS2005 and the new framework 2.0 is out to the public now. Wondering about some things. When you install the new framework 2.0 can a person still use visual studio 2003 or...
56
by: Rob Dob | last post by:
VS2005 is a PIECE of Garbage and is bug Ridden, I wonder how many others feel the same, I am so sorry that I have moved away from VS2003, VS2005 is unstable, and half the stuff doesn't work, ...
5
by: Rob Roberts | last post by:
Is there any way to change VS2005 to generate HTML 4.01/Strict instead of XHTML 1.0/Transititional? VS2005 puts a DOCTYPE statement specifying XHTML 1.0/Transitional at the top of every new aspx...
11
by: rk | last post by:
According to the docs, I would expect to check the result of an OpenFileDialog in a VS 2005 CLR Windows Forms application this way: if (openFileDialog1->ShowDialog()== DialogResult::OK) ...
9
by: Rick | last post by:
Hi guys!! just one question, can i send pointers from VC++ 2005 to a vc++ 6.0 dll? if it is possible, how can i do this? does VS2005 have rules to send pointers? Regards.
2
by: scarleton | last post by:
A coworker and I have spent the last day and a half trying to track down this bug in our code. We found the solution and thought we might post it to help others out... The setup: Class...
2
by: Code Monkey | last post by:
I've just developed an Windows application that uses Crystal Reports (v10 ? - the version that ships with VS2005). Whilst the application works fine - reports can be viewed on the development...
5
by: Kardon Coupé | last post by:
Dear All, I'm bemused, I'm moving an application I've written from VB6 into VS2005, and I'm getting all the fundamentals over before I delve into the hard part, like getting the forms layout...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.