W3C validation

F

Fredrik Elestedt

Hi,

I've been trying to get a ASP.NET site I'm working on validated as HTML 4.01
Transitional but I've run into a couple of problems - actually the only ones
left before the page is validated...

1: the ID tags on serverside controls start with a char which is not allowed
(in this case '_'), example is a Label:
<span id="_ctl0_labDate">

2: postback buttons (inputs with type submit) gets a language parameter
defined which is not allowed in transitional:
<input name="_ctl0:btnAddPreDefined" value="Lägg till" onclick="if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "
language="javascript" id="_ctl0_btnAddPreDefined" type="submit">
 
F

Fredrik Elestedt

Forgot the question :)

Anyone know how to fix the problems I described?

Thanks in advance
// Fredrik
 
B

Bob Lehmann

I've been trying to get a ASP.NET site I'm working on validated as HTML
4.01
Why?

Do your pages behave the way you would like them to in the browsers you
tested?

If so, what's the problem? If not, why don't you fix them?

Bob Lehmann
 
M

Micael Baerens

Hello Fredrik,
1: the ID tags on serverside controls start with a char which is not
allowed
(in this case '_'), example is a Label:
<span id="_ctl0_labDate">

You can avoid this by giving the containing control an ID instead of omitting it.

<form runat="server"/>
<asp:Label ID="labDate" Runat="server"/>
</form>

Generates what you are seeing - instead try:

<form ID="myForm" runat="server"/>
<asp:Label ID="labDate" Runat="server"/>
</form>

this generates "myForm_labDate" as an ID for the label.
2: postback buttons (inputs with type submit) gets a language
parameter
defined which is not allowed in transitional:
<input name="_ctl0:btnAddPreDefined" value="Lägg till" onclick="if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "
language="javascript" id="_ctl0_btnAddPreDefined" type="submit">

I have never noticed this? But a solution could be to apply a page filter to your page, that post-processes the output to ensure validity. It's not the prettiest solution, but for .NET 1.1 I think it is the best. A good article on the subject, albeit XHTML output: http://www.aspnetresources.com/articles/HttpFilters.aspx
 
F

Fredrik Elestedt

They behave as I want - but only because the browsers tested doesn't follow
the W3C standard ti the letter...

I don't know how to fix it since the names are genereated by ASP.NET

// Fredrik
 
F

Fredrik Elestedt

Thanks for the reply,

I have an ID on the form though - but .NET still sets it to __aspNetForm
Don't know how to override this...

// Fredrik
 
M

Micael Baerens

Hello Fredrik,
I have an ID on the form though - but .NET still sets it to
__aspNetForm Don't know how to override this...

This seems very wierd - what version of .NET are you using?

When I use the following on .NET 1.1:

<html>
<head>
<title>X</title>
</head>
<body>
<form id="myForm" method="post" runat="server">
<asp:Label ID="labDate" Runat="server"/>
</form>
</body>
</html>

I get the following output:

<html>
<head>
<title>X</title>
</head>
<body>
<form method="post" action="X.aspx" id="myForm">
<div><input type="hidden" name="__VIEWSTATE" value="dDw5MjMzODA0MjI7Oz4c0eeC9LGZJ2oNUcAEtyn4P0c3nQ==" /></div>

<span id="labDate"></span>
</form>
</body>
</html>

(the control isn't actually prefixed by myForm as I wrote earlier).

Kind Regards,
Micael Baerens ([email protected])
 
F

Fredrik Elestedt

I have .NET 1.1 SP1 running on Win2k3

That is what my page looks like - except that there are alot more
components...

I found what causes that error - I'm using a template system...
For some reason it overrides the ID on the form to
__aspnetFormwould be nice to fix this - tried setting it programmatically,
no difference.// Fredrik
 
F

Fredrik Elestedt

Well,

I managed, finally, to get it to set the id on the label to testing_labDate
instead of __labDate.
In the loaded template control I added this.ID = "testing";

But the form ID is unfortunantly still __aspnetForm
Any ideas?
 
M

Micael Baerens

Hello Fredrik,
I managed, finally, to get it to set the id on the label to
testing_labDate
instead of __labDate.
In the loaded template control I added this.ID = "testing";
But the form ID is unfortunantly still __aspnetForm Any ideas?

I don't know which templating solution you are using, but options might include inheriting from the template class to change the behaviour if possible, using the page filtering solution as described earlier or maybe manipulating the form to set a different ID, like:

Control control = Page.FindControl( "__aspnetForm" );
control.ID = "aspnetForm";

though this is very hacky and may cause something to stop working.

Kind Regards,
Micael Baerens ([email protected])
 
B

Bob Lehmann

Yes, I am serious.

His, apparently non-valid HTML is functioning on his target platforms. What
is to be gained by making it "valid"?

Especially since, as the OP mentioned "because the browsers tested doesn't
follow W3C standard ti the letter..."

Are you suggesting that making his HTML "valid", but non-functional, would
be a step in the right direction?

Bob Lehmann
 
F

Fredrik Elestedt

Micael,

Well, thanks anyway - guess i'll have to live with it for now...

// Fredrik
 
M

Marc Jennings

Yes, I am serious.

His, apparently non-valid HTML is functioning on his target platforms. What
is to be gained by making it "valid"?

Nothing more than making sure that a single set of code will work
across all platforms.
Especially since, as the OP mentioned "because the browsers tested doesn't
follow W3C standard ti the letter..."

Are you suggesting that making his HTML "valid", but non-functional, would
be a step in the right direction?

Not at all. I am suggesting that the code could be presented in a
single version to all browsers, and an acceptable result would be
visible to all. This is the reason we have standards. It was never
said that the proposed valid version would *not* work on the target
platform

OT, and slightly rant-like....

If vendors want to "extend" the functionailty of their product by
adding "features", that is fuine, but if these new features mean that
the rest of the standard is broken then there is something seriously
wrong. Let's look at it from another POV. Let's imagine that Outlook
was updated with a new engine that could sort email by the number of
characters in the mail body, but adding that feature meant that the
from address suddenly becomes unreadable in the interface - would that
be acceptable?
 
F

fiur

I am also in search of a solution to this problem and found a
explanation on another site. Apparently asp.net change names when th
form is placed in a user control (ascx). Place the form in a aspx-pag
instead and keep the id. If you have the possibility to do that.
don't have that possibility unfortunately....

Good luck


-
fiu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,786
Messages
2,569,626
Members
45,328
Latest member
66Teonna9

Latest Threads

Top