Form Name, ID and validator.w3.org

  • Thread starter Thread starter Brian Cryer
  • Start date Start date
B

Brian Cryer

I originally posted this on microsoft.public.dotnet.languages.vb but didn't
get a response. I suppose that whilst I'm using VB.NET this is probably I
generic .NET issue so I'm hoping someone will be able to help ...

I'm working on a web site (using VB.NET) where the customer is keen that all
the pages pass the W3C markup validation service (at
http://validator.w3.org). Whilst this has thrown up a number of items, I can
understand most and address them. But I'm stuck on one, what I'm hoping is
that someone could tell me why, whether I can do anything about it (or
whether its best to leave it as is):

Line blah, colum blah: there is no attribute "NAME"
<form name="Form1" method="post" action="default.aspx" id="Form1">

looking at the html inside VB.Net I have the line:

<form id="Form1" method="post" runat="server">

and I assume it is this line which is rendered as above in the browser. So,
in summary:

1. Why is name="Form1" added?
2. Can I disable this?
3. If I can disable it then should I? (Is it there for backwards
compatibility?)

Thanks in advance,

Brian

www.cryer.co.uk/brian
 
Brian Cryer wrote:

I'm working on a web site (using VB.NET) where the customer is keen that all
the pages pass the W3C markup validation service (at
http://validator.w3.org). Whilst this has thrown up a number of items, I can
understand most and address them. But I'm stuck on one, what I'm hoping is
that someone could tell me why, whether I can do anything about it (or
whether its best to leave it as is):

Line blah, colum blah: there is no attribute "NAME"
<form name="Form1" method="post" action="default.aspx" id="Form1">

looking at the html inside VB.Net I have the line:

<form id="Form1" method="post" runat="server">

and I assume it is this line which is rendered as above in the browser. So,
in summary:

1. Why is name="Form1" added?
2. Can I disable this?
3. If I can disable it then should I? (Is it there for backwards
compatibility?)

I suppose so, some parts of ASP.NET require client-side script to work
to get a postback from a control and with older browsers scripting of
forms might use
document.Form1
or
document.forms.Form1
only if a name attribute is present.

As for the validator, you can certainly validate that snippet by
declaring your page as being HTML 4.01 Transitional.
 
Martin Honnen said:
Brian Cryer wrote:



I suppose so, some parts of ASP.NET require client-side script to work to
get a postback from a control and with older browsers scripting of forms
might use
document.Form1
or
document.forms.Form1
only if a name attribute is present.

As for the validator, you can certainly validate that snippet by declaring
your page as being HTML 4.01 Transitional.

Thank's Martin.

What you say makes perfect sense and seems very sensible.

Regarding the validator, my page already has <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"> at the top ... aargh ... YOU ARE
RIGHT, changing this to 4.01 and this problem went away.

I owe you one. Thanks.

kind regards,

Brian

www.cryer.co.uk
 
Back
Top