By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,836 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,836 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
"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

P: n/a

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

P: n/a
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

P: n/a
>> 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

P: n/a

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

P: n/a

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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.