Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 5th, 2009, 10:33 AM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default 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.
  #2 (permalink)  
Old March 6th, 2009, 10:42 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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">
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
  #3 (permalink)  
Old March 6th, 2009, 10:55 AM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

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.
  #4 (permalink)  
Old March 6th, 2009, 11:10 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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 />).
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
  #5 (permalink)  
Old March 6th, 2009, 11:22 AM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

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

Last edited by Will; March 6th, 2009 at 11:26 AM..
  #6 (permalink)  
Old March 10th, 2009, 12:26 PM
Friend of Wrox
 
Join Date: Feb 2009
Posts: 194
Thanks: 5
Thanked 3 Times in 3 Posts
Default

anymore suggestions?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I use Visual Studio 2008 Kevin7777 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 25 March 7th, 2009 08:27 AM
Help with Visual Studio 2008 IDE dotnetDeveloper Visual Studio 2005 1 December 6th, 2008 12:55 PM
very new to Visual Studio 2008 Joel Saren Visual Basic 2008 Essentials 2 June 6th, 2008 03:27 PM
Visual studio 2008 - wap Feodorov Other Programming Languages 1 March 11th, 2008 09:17 PM
Visual Studio 2008 looks juzjess Intro Programming 0 October 26th, 2007 03:35 PM



All times are GMT -4. The time now is 02:20 PM.


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