473,320 Members | 1,794 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,320 software developers and data experts.

Can I write *valid* HTML with ASP.NET ?

Hello,

I am a complete and utter newbie at ASP.NET, so please forgive any
stupid questions ;-)

I am just trying to get my head around the whole web forms business, but
have run into a problem. I have been a web designer for many years and
have always made a specific point of writing HTML that is valid
according to W3C specifications. With web forms, the .NET framework
seems to generate some of the HTML, and what it generates is not valid.

For example, there is no attribute "name" in the HTML specs, but this is
generated for form elements. Also, the content of an "id" element cannot
start with an underscore according to the specs, but the hidden input
fields that it generates to keep state use just this.

It seems a shame that MS have put all this effort into (what looks like)
a very powerful framework, then ruined it by generating invalid HTML
that is likely to choke non-IE browsers. I hope I'm wrong here and
there's some way around this.

Looking forward to being corrected (nicely please !!)

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #1
7 1412
"Alan Silver" <al*********@nospam.thanx> wrote in message
news:1m**************@nospamthankyou.spam...
Hello,

I am a complete and utter newbie at ASP.NET, so please forgive any
stupid questions ;-)

I am just trying to get my head around the whole web forms business, but
have run into a problem. I have been a web designer for many years and
have always made a specific point of writing HTML that is valid
according to W3C specifications. With web forms, the .NET framework
seems to generate some of the HTML, and what it generates is not valid.

For example, there is no attribute "name" in the HTML specs, but this is
generated for form elements. Also, the content of an "id" element cannot
start with an underscore according to the specs, but the hidden input
fields that it generates to keep state use just this.
"name" certainly is an attribute defined in the W3C specs you make mention
of:
(http://www.w3.org/TR/1998/REC-html40...html#adef-name
-INPUT)
likewise the same is true for "id"
http://www.w3.org/TR/1998/REC-html40...l.html#adef-id

As a pratical matter, without specifying either attribute, how would one
manipulate DOM objects?
This is a matter that predates the .Net framework.

Are you sure you are "a web designer for many years"?
It seems a shame that MS have put all this effort into (what looks like)
a very powerful framework, then ruined it by generating invalid HTML
that is likely to choke non-IE browsers. I hope I'm wrong here and
there's some way around this.


"likely" as in meaning you haven't actually created a product using the
framework.
If it was really generating browser choking HTML, there would be quite an
uproar
on this newsgroup long ago.

The source for generating invalid HTML may lie elsewhere....

--
Peter O'Reilly
Nov 18 '05 #2

You can absolutely write valid HTML with ASP.NET ..... now that said, XHTML strict is not possible (specifics you've noted); and for XHTML transitional one has to rely on the "transitional"

We develop using HTML 4.01 and XHTML 1.0 transitional and have pretty good results with IE, Gecko, Safari and Opera (actually, for how we develop -- to as close to standards as is possible -- often times it IE that doesn't grok our HTML).

Now, our generated pages don't yet pass the w3.org validation, they come close (again, you've noted some of the reasons) -- but on a practical level we get great results in a variety of browsers.

It's my understanding that Whidbey will be XHTML 1.0 standards friendly (and if it's not, I'm done with ASP.NET).

Scott
"Alan Silver" <al*********@nospam.thanx> wrote in message news:1m**************@nospamthankyou.spam...
Hello,

I am a complete and utter newbie at ASP.NET, so please forgive any
stupid questions ;-)

I am just trying to get my head around the whole web forms business, but
have run into a problem. I have been a web designer for many years and
have always made a specific point of writing HTML that is valid
according to W3C specifications. With web forms, the .NET framework
seems to generate some of the HTML, and what it generates is not valid.

For example, there is no attribute "name" in the HTML specs, but this is
generated for form elements. Also, the content of an "id" element cannot
start with an underscore according to the specs, but the hidden input
fields that it generates to keep state use just this.

It seems a shame that MS have put all this effort into (what looks like)
a very powerful framework, then ruined it by generating invalid HTML
that is likely to choke non-IE browsers. I hope I'm wrong here and
there's some way around this.

Looking forward to being corrected (nicely please !!)

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #3
In article <eb**************@TK2MSFTNGP09.phx.gbl>, Scott G.
<no*****@this-is-extra-hotmail.com> writes
*Now, our generated pages don't yet pass the w3.org validation, they
come close (again, you've noted some of the reasons) -- but on a
practical level we get great results in a variety of browsers.


There's the rub (to quote WS). We are aiming for 100% valid according to
W3C specs. We always have.

How do you modify what the framework produces ?

Thanx

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #4
>> I am a complete and utter newbie at ASP.NET, so please forgive any
stupid questions ;-)

I am just trying to get my head around the whole web forms business, but
have run into a problem. I have been a web designer for many years and
have always made a specific point of writing HTML that is valid
according to W3C specifications. With web forms, the .NET framework
seems to generate some of the HTML, and what it generates is not valid.

For example, there is no attribute "name" in the HTML specs, but this is
generated for form elements. Also, the content of an "id" element cannot
start with an underscore according to the specs, but the hidden input
fields that it generates to keep state use just this.
"name" certainly is an attribute defined in the W3C specs you make mention
of:
(http://www.w3.org/TR/1998/REC-html40...html#adef-name
-INPUT)
likewise the same is true for "id"
http://www.w3.org/TR/1998/REC-html40...l.html#adef-id


Sorry, I wasn't quite clear enough. Obviously *some* elements have those
attributes, they are required for anything useful. My problem was that
the generated pages had them for elements that didn't allow them (can't
check now as I don't have access to the machine with it loaded). The
generated pages failed the W3C validation fairly badly.
As a pratical matter, without specifying either attribute, how would one
manipulate DOM objects?
This is a matter that predates the .Net framework.
Yup, see above.
Are you sure you are "a web designer for many years"?
Yup, about nine years and proud of it. I pride myself on producing 100%
valid web sites. Always have,
It seems a shame that MS have put all this effort into (what looks like)
a very powerful framework, then ruined it by generating invalid HTML
that is likely to choke non-IE browsers. I hope I'm wrong here and
there's some way around this.


"likely" as in meaning you haven't actually created a product using the
framework.


Nope, I have tried it. As I explained at the start, I am a complete
newbie in it, so I cannot claim any expertise. I followed some simple
tutorials to try and learn.
If it was really generating browser choking HTML, there would be quite an
uproar
on this newsgroup long ago.
The HTML I saw didn't choke the browser, it was invalid. My reference to
choking was a more general comment on the effects of invalid HTML. I
only observed harmless, but invalid HTML. My concern was that if the
framework produces invalid HTML on simple examples, it may produce more
seriously invalid HTML in more complex cases.
The source for generating invalid HTML may lie elsewhere....


Nope, the framework. It may be possible to get around it, but it was
definitely the framework producing the invalid stuff.

Ta ra

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #5

Well, it's a long story, but for things like that are fundamental to ASP.NET -- _'s IDs and the deprecated name attribute; there's nothing one can do (I take that back, I guess you could re-engineer using handlers, but if you do that, what's the point, you might as well use something else).

For a bunch of the other "problems", like UPPER case elements, we've rewritten a lot of the controls (mostly via subclassing) anyway, so we just fixup the tag names there (and other deprecated attributes)... some things you can't fix via subclassing, for example there's no way to get ride of the "style=" on a DataGrid (which isn't really a standards problem per-se, but is annoying none the less).

You should able to do some quick experiments; get a basic page and stick the doctype you want to use and just add some controls -- run it through the validators.... as I mentioned we do really well with XHTML 1.0 transitional; but that's really a practical thing: we test the heck out of out HTML and sometimes have to tweak to get page the way our users expect it to behave (and in those cases standards go out the door).

There's a company that sells XHTML controls that are a replacement for the builtin stuff; I've never used them, but, since the ASP.NET isn't XHTML 1.0 strict friendly, I'm not sure how using those controls get you where you want to be.

All of what I've said applies to XHMTL, we stopped doing HTML 4.0 a while ago -- so someone else might have a better idea about the state of compliance.

Of course, if all you are shooting for is HTML 3.2 you should have no problems at all :)

Scott
"Alan Silver" <al*********@nospam.thanx> wrote in message news:i0**************@nospamthankyou.spam...
In article <eb**************@TK2MSFTNGP09.phx.gbl>, Scott G.
<no*****@this-is-extra-hotmail.com> writes
Now, our generated pages don't yet pass the w3.org validation, they
come close (again, you've noted some of the reasons) -- but on a
practical level we get great results in a variety of browsers.


There's the rub (to quote WS). We are aiming for 100% valid according to
W3C specs. We always have.

How do you modify what the framework produces ?

Thanx

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #6

Oh, one more thing, the VS.NET editor will likely drive you crazy (it's constantly changing my <br /> to <br> etc...)

Scott

"Alan Silver" <al*********@nospam.thanx> wrote in message news:i0**************@nospamthankyou.spam...
In article <eb**************@TK2MSFTNGP09.phx.gbl>, Scott G.
<no*****@this-is-extra-hotmail.com> writes
Now, our generated pages don't yet pass the w3.org validation, they
come close (again, you've noted some of the reasons) -- but on a
practical level we get great results in a variety of browsers.


There's the rub (to quote WS). We are aiming for 100% valid according to
W3C specs. We always have.

How do you modify what the framework produces ?

Thanx

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #7
In article <#a**************@TK2MSFTNGP12.phx.gbl>, Scott G.
<no*****@this-is-extra-hotmail.com> writes
Well, it's a long story

<snip>

Thanx for the reply. I don't think I'll bother. I'm actually very happy
with ASP and haven't really been convinced of the advantages of .NET
anyway. I thought this would be a good opportunity to try it out, but if
I am going to have to work that hard just to get valid HTML, then I
might as well go back to ASP. I have a good set of library routines and
well-defined coding practices there.

Thanx for the reply.

--
Alan Silver
(anything added below this line is nothing to do with me)
Nov 18 '05 #8

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

Similar topics

2
by: gruddo | last post by:
Hi this is my first post. I have two webservers. I can run php code fine on one but not the other. Both webservers can read files only one can write. I have looked around at other posts and they...
6
by: ok | last post by:
<img src="http://www.6park.com/enter2/av.gif" onload="document.write('an iframe obj');"> First of all, it destroy the HTML page. Secondly even if it does not destroy it, the iframe object will...
7
by: Remi Bastide | last post by:
I'm trying to open a blank window and write a message in it. The following page works as expected in IE, but in Firefox the message is not written: <HTML> <HEAD> <TITLE>Document.write...
2
by: Eric Mitchell | last post by:
Hello all, I am using the document.write() method to create new content on the same page, however... I need to create a new button using this method (button in HTML). Complicating the matter...
12
by: Radek Maciaszek | last post by:
Hi It's very interesting problem. I couldn't even find any inforamtion about it on the google. I think that the best way of explain will be this simple example: <html> <body> <script...
12
by: Sean | last post by:
Hi, I have the following script: ----------------------------------------------------------------------------------- <script type="text/javaScript"> <!-- document.write('<div...
2
by: Adam | last post by:
This is frustrating me. Opening IE displays the following code fine. When I open a new window the code no longer works. All the HTML is overwritten with the first document.write statement. Tried...
10
by: Geoff | last post by:
I am using the following statement in a script: If (res == 123) document.write (" Blah Blah"); else document.write (" XYZ"); This of course brings up a new page on my site and prints Blah...
11
by: Michael Powe | last post by:
How can I make an XHTML-compliant form of an expression in this format: document.write("<scr"+"ipt type='text/javascript' src='path/to/file.js'>"+"</scr"+"ipt>"); this turns out to be a...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.