p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 3.5 Basics (http://p2p.wrox.com/forumdisplay.php?f=351)
-   -   Validation-visual Studio 2008 (http://p2p.wrox.com/showthread.php?t=73104)

Will March 5th, 2009 10:33 AM

Validation-visual Studio 2008
 
I am building a website and currently I have had a few issues with getting it to validate properly.

I had built my site to validate to xhtml 1.1 strict and it would validate fine on my local machine but when uploaded to the server I got 2 errors and this was because the ASP.NET was not generating some of the code to xhtml stict standards.

So after abit of research on the msdn documentation I found that you could alter the way the asp.net generates html in the web config file by setting the xhtmlConformance to strict, transitional etc I set it to strict.

After uploading the new webconfig file the site would still not validate in the w3c generator but when looking at the source in code through developer tool bar add on for firefox it told me that is was valid.

Imar then suggested in another post I made that the w3c validator probably was telling the asp.net that it couldn't serve strict markup and so it was changing it specifically for the validator (or something to that extent) so I just left it at that content that the actual markup was valid even if it wasn't being detected.

After reading a few articles and some research into why my site was appearing funny in a few browsers I decided that a strict html 4.01 doctype would server me better. So after changing the doctype and consequently the closing tags to conform to the new doctype and removing the xhtmlConformance from the webconfig file and uploading my site I find that it doesn't validate.

this time the validation errors are that my tags that are being generated are all because they are closed like /> instead of >. I don't understand why this is the case however as it has a html strict doctype and my page code everything is closed > accordingly.

So to summarise after that long post, I can't get asp.net to generate valid html code to comply with the doctype I have chosen the page to use. If anybody can help this would be great as I feel that solving this problem will help my sites display better amongst all the browsers.

To see the validation errors I am having with the current doctype tag plese click here.

The code for my MasterPage is here:
Code:
<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head runat="server">
<title>Parker Designs</title>
<link href="~/Styles.css" type="text/css" rel="Stylesheet">
<!--[if IE 6]>
<link href="ie-styles.css" type="text/css" rel="Stylesheet">
<![endif]-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="Keywords" content="Website, Design, Development, .NET, Will Parker, web designer, website designer, website developer, web developer">
<meta name="Description" content="Online portfolio for Will Parker a freelance website designer and .NET developer.">
<meta name="Author" content="william2002uk@hotmail.com">
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">

<!--*******************Page Wrapper******************-->
<div id="wrapper">

<!--********************Header**********************-->
<div id="header">
<a href="Default.aspx"></a>
</div>
<!--******************End of Header***************-->

<!--*****************Navigation***************-->
<div id="nav">
<ul>
<li><a href="Default.aspx">Home</a></li>
<li><a href="portfolio.aspx">Portfolio</a></li>
<li><a href="services.aspx">Services</a></li>
<li><a href="contact.aspx">Contact</a></li>
</ul>
</div>
<!--***************END of Navigation************-->

<!--**************main-content***************-->
<div id="main-content">

<!--***************leftcol placeholder****************-->
<div id="leftcol">
<asp:ContentPlaceHolder id="leftcolcon" runat="server">

</asp:ContentPlaceHolder>
</div>
<!--******************End of leftcol placeholder*********-->

<!--******************rightcol************-->
<div id="rightcol">
<h3>News & Updates 4th March 2009:</h3>
<p>Current portfolio website is nearly complete. Upon it's completion this portfolio will be transferring to my new domain www.will-parker.com</p>
<h3>Recent projects...</h3>
<img src="Images/Jade-Valley-250x165.jpg" alt="Jade Valley" class="photo" title="Image of Parker Designs redesign of the Jade Valley website">
<p>Jade Valley redesign click <a href="portfolio.aspx">here</a> to find out more.</p>

</div>
<!--***************End of rightcol************-->

</div>
<!--**************END of main-content********-->
<div class="clearfooter"></div>
</div>
<!--*********************End of wrapper****************-->

<!--***************footer*****************-->
<div id="footer">

<ul class="footernav">
<li><a href="Default.aspx">Home</a></li>
<li><a href="portfolio.aspx">Portfolio</a></li>
<li><a href="services.aspx">Services</a></li>
<li><a href="contact.aspx">Contact</a></li>
<li>&copy; 2009 <a href="Default.aspx">Parkerdsgn.com</a></li>
</ul>


</div>
<!--**********************End of Footer*********-->

</form>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7763810-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
Which in turn generates this html:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

<head><title>
Parker Designs- Freelance website designer and developer, Will Parker
</title><link href="Styles.css" type="text/css" rel="Stylesheet" />
<!--[if IE 6]>
<link href="ie-styles.css" type="text/css" rel="Stylesheet" />
<![endif]-->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><meta name="Keywords" content="Website, Design, Development, .NET, Will Parker, web designer, website designer, website developer, web developer" /><meta name="Description" content="Online portfolio for Will Parker a freelance website designer and .NET developer." /><meta name="Author" content="william2002uk@hotmail.com" />
</head>
<body>
<form name="aspnetForm" method="post" action="Default.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwMDUyNjYzMjhkZIm1knYf545rNmWGHN+LPAZ4AFT f" />
</div>


<!--*******************Page Wrapper******************-->
<div id="wrapper">

<!--********************Header**********************-->
<div id="header">
<a href="Default.aspx"></a>
</div>
<!--******************End of Header***************-->

<!--*****************Navigation***************-->
<div id="nav">
<ul>
<li><a href="Default.aspx">Home</a></li>
<li><a href="portfolio.aspx">Portfolio</a></li>
<li><a href="services.aspx">Services</a></li>
<li><a href="contact.aspx">Contact</a></li>
</ul>
</div>
<!--***************END of Navigation************-->

<!--**************main-content***************-->
<div id="main-content">

<!--***************leftcol placeholder****************-->
<div id="leftcol">

<h1>Parker Designs..Whats it all about?</h1>

<p>Parker Designs is a web-based company and online portfolio designed, built and maintained by Will Parker, dedicated to designing and coding w3c accessible, standards compliant websites. Whether you require a simple static page website or a more complex database driven one it isn’t a problem.</p>

<h2>Why Parker Designs?</h2>
<p>There are no shortage of Web designers and developers on the market so why should you choose me? I can offer an affordably priced website that <em>you</em> want to suit <em>your</em> needs. Just check out my <a href="portfolio.aspx">portfolio</a> to see some of my most recent works.</p>
<h2>How to get in touch</h2>
<p>If you would like to contact me to discuss working on a website for you then please click the contact me link in the navigation or click <a href="contact.aspx">here</a> to be taken straight to the contact page. If you would rather find out a bit more about me and what I offer first then please head over to the <a href="services.aspx">services</a> page. I hope to hear from you soon.</p>


</div>
<!--******************End of leftcol placeholder*********-->

<!--******************rightcol************-->
<div id="rightcol">
<h3>News & Updates 4th March 2009:</h3>
<p>Current portfolio website is nearly complete. Upon it's completion this portfolio will be transferring to my new domain www.will-parker.com</p>
<h3>Recent projects...</h3>
<img src="Images/Jade-Valley-250x165.jpg" alt="Jade Valley" class="photo" title="Image of Parker Designs redesign of the Jade Valley website">
<p>Jade Valley redesign click <a href="portfolio.aspx">here</a> to find out more.</p>

</div>
<!--***************End of rightcol************-->

</div>
<!--**************END of main-content********-->
<div class="clearfooter"></div>
</div>
<!--*********************End of wrapper****************-->

<!--***************footer*****************-->
<div id="footer">

<ul class="footernav">
<li><a href="Default.aspx">Home</a></li>
<li><a href="portfolio.aspx">Portfolio</a></li>
<li><a href="services.aspx">Services</a></li>
<li><a href="contact.aspx">Contact</a></li>
<li>&copy; 2009 <a href="Default.aspx">Parkerdsgn.com</a></li>
</ul>


</div>
<!--**********************End of Footer*********-->

</form>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7763810-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
Thanks in advance. Hope it isn't too confusing.

Martin Honnen March 6th, 2009 10:42 AM

First of all I would not choose XHTML 1.1 on the web as you are supposed to serve it as application/xhtml+xml which IE does not support at all.
Choose HTML 4 or XHTML 1.0.
The validation problem you have is because ASP.NET returns empty elements with the proper XML syntax (e.g. <link ... />) while you have included an HTML doctype. With HTML 4 you would need e.g. <link ...>.
So one way to solve the validation problem should be to use an XHTML 1.0 doctype e.g.
Code:

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


Will March 6th, 2009 10:55 AM

I agree with you about the doctype tags but I want to use html 4 for reasons which are presented in this article here.

and at the moment the differences between xhtml 1.0 and 1.1 are not so far apart.

For these reasons I would rather find a way to get it to validate html as opposed to xhtml, i mean there must be some way? Other than just not using it at all.

thanks for the help so far though.

Martin Honnen March 6th, 2009 11:10 AM

If you want to use HTML 4.01 then in your web.config you need
[code
<system.web>
<!-- other elements here -->
<xhtmlConformance
mode="Legacy" />
</system.web>

[/code]
It is a bit confusing that the element says xhtmlConformance but then the mode="Legacy" disabled XHTML. Nevertheless according to http://msdn.microsoft.com/en-us/library/ms178159.aspx that setting should disable XHTML and output the markup the HTML way (e.g. <br> instead of <br />).

Will March 6th, 2009 11:22 AM

Thank you I didn't pick up on that legacy but there.

Thanks alot this should hopefully solve my problems.

EDIT: Visual Studio disagrees and that caused 39 validation errors and now my floats don't work...:-( lol

Will March 10th, 2009 12:26 PM

anymore suggestions?


All times are GMT -4. The time now is 08:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.