[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 453
  • Last Modified:

ASP.NET: How to do without Doctype

Hi there,
I estensively use tables for positionning my control on the page (although I know the tables were not made for that). The default measurement of the controls in in percentage. I found ou that when I use Doctype, the table are rendered weird. Scroll bars appears without any need.
So decided to work without doctype.
Recentlty I was working with ModalPopupExtender and the result was worse. I use the css attached in the snippet as the background css class. The control works well but the background is really ugly. I put back doctype and things works  perfeclty as the Modal popup is concerned.
Can any one help me solve this without using DocType?
0
karakav
Asked:
karakav
  • 6
  • 5
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
which doctype are you giving?

Can you also post the source code?
Thanks
0
 
karakavAuthor Commented:
I use this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
0
 
Gurvinder Pal SinghCommented:
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
amit_gCommented:
Something must be wrong with the tables. You should not remove the DOCTYPE to solve that problem because it would cause other problems as you have already experienced. You would also face problems when you get to the multiple browser testing as without DOCTYPE each browser would render the same code differently because it won't know what standard to use. Have you tried the default DOCTYPE that the VS uses

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
0
 
karakavAuthor Commented:
amit_q, I used the doctype you recommend but the textboxes and dropdownlist render weird.
0
 
amit_gCommented:
Can't say why they are looking weird but removing the doctype is not a good idea. Do you have it online for us to see. Also what browser are you targeting/testing?
0
 
karakavAuthor Commented:
Just give me time to make a sample page as I am not allowed to make public the project I am working on.

I am targetting IE6 to IE8 and Firefox 2.0 and above
0
 
amit_gCommented:
Since you are targeting these browsers (IE6 and IE8 are quite different), you can't afford to drop DOCTYPE. Without that each browser would render it differently. For IE6 you would have to anyway make some extra efforts to render properly anyway. I would recommend testing first in IE8/FF3. Both of these follow standards. Then you can apply the updates/hacks for the IE6.
0
 
karakavAuthor Commented:
Here is the code. I made a project with one page. I included a theme on the project as my self use them. For the website to be operational, you need to remove the txt extention on the following files:
- Default.aspx.cs.txt
- Default.aspx.txt
- web.config.txt
- SkinFile.skin.txt

You need also the add a reference to the ajaxcontroltookit dll file.

I am sorry for the incoveniences but I wanted to provide the closest picture of the problem.

The try to run the website with and then without the doctype, to see the difference in the rendering.

Thanks in advance.
TestSite.zip
0
 
amit_gCommented:
Looks same with DOCTYPE and without it in both IE8 an FF. I noticed that you are using the older version of assemblies

System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

the latest version is

System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35

Also what are using to develop?
0
 
karakavAuthor Commented:
It doesn't look the same. Pay attention to the sizes of the controls. Without doctype, they render well aligned.

I use Visual Studio 2005 to develop.
0
 
amit_gCommented:
The slight difference is due to the differences in box model that is used in quirks mode (no doctype) and standard mode. Even though you may say it looks correct in quirks mode what you are seeing is how it is rendering in quirks mode. That would most likely look broken in different browsers because the quirks mode is different in each browser. The solution is to write the HTML for the latest and standard compliant browser. The "correct rendering" can still be done in standard complaint HTML but you will have to write a different HTML for that. That HTML would render same in all the standard complaint browsers. Take a look at http://www.cs.tut.fi/~jkorpela/quirks-mode.html and then you would see that a width:100% results in different pixel width in quirks mode and standard mode and that is why you see a difference of few pixel.

To answer your question, if you should use a DOCTYPE or not, the answer is you should use it. You can achieve whatever rendering you want in the standard mode, however the HTML and CSS would be different. The solution is to change the HTML/CSS to get to what you want without removing the DOCTYPE.

If you post this difference in HTML/CSS zone, someone can give you the correct and standard compliant HTML/CSS that would render exactly like you want. You should post the simple HTML and CSS, not the whole application because many HTML/CSS experts may not be able to run a ASP.NET application.
0
 
karakavAuthor Commented:
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now