W3C validation

Discussion in 'ASP .Net' started by Fredrik Elestedt, Nov 25, 2004.

  1. 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">
    Fredrik Elestedt, Nov 25, 2004
    #1
    1. Advertising

  2. Forgot the question :)

    Anyone know how to fix the problems I described?

    Thanks in advance
    // Fredrik

    "Fredrik Elestedt" <> wrote in message
    news:%...
    > 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">
    >
    Fredrik Elestedt, Nov 25, 2004
    #2
    1. Advertising

  3. Fredrik Elestedt

    Bob Lehmann Guest

    > 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

    "Fredrik Elestedt" <> wrote in message
    news:%...
    > 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">
    >
    >
    Bob Lehmann, Nov 26, 2004
    #3
  4. 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
    Micael Baerens, Nov 26, 2004
    #4
  5. 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

    "Bob Lehmann" <> wrote in message
    news:%...
    >> 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
    >
    > "Fredrik Elestedt" <> wrote in message
    > news:%...
    >> 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">
    >>
    >>

    >
    >
    Fredrik Elestedt, Nov 26, 2004
    #5
  6. 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

    "Micael Baerens" <> wrote in message
    news:enWE$...
    > 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
    >
    >
    Fredrik Elestedt, Nov 26, 2004
    #6
  7. 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 ()
    Micael Baerens, Nov 26, 2004
    #7
  8. 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
    "Micael Baerens" <> wrote in message
    news:%...
    > 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 ()
    >
    Fredrik Elestedt, Nov 26, 2004
    #8
  9. 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?

    "Micael Baerens" <> wrote in message
    news:%...
    > 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 ()
    >
    Fredrik Elestedt, Nov 26, 2004
    #9
  10. 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 ()
    Micael Baerens, Nov 26, 2004
    #10
  11. Fredrik Elestedt

    Bob Lehmann Guest

    If they work, then why do you need to fix them?

    Bob Lehmann

    "Fredrik Elestedt" <> wrote in message
    news:...
    > 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
    >
    > "Bob Lehmann" <> wrote in message
    > news:%...
    > >> 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
    > >
    > > "Fredrik Elestedt" <> wrote in message
    > > news:%...
    > >> 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">
    > >>
    > >>

    > >
    > >

    >
    >
    Bob Lehmann, Nov 26, 2004
    #11
  12. Please tell me you're not serious. Please?

    On Fri, 26 Nov 2004 06:50:23 -0700, "Bob Lehmann"
    <> wrote:

    >If they work, then why do you need to fix them?
    >
    >Bob Lehmann
    >
    >"Fredrik Elestedt" <> wrote in message
    >news:...
    >> 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
    >>
    >> "Bob Lehmann" <> wrote in message
    >> news:%...
    >> >> 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
    >> >
    >> > "Fredrik Elestedt" <> wrote in message
    >> > news:%...
    >> >> 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">
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    Marc Jennings, Nov 26, 2004
    #12
  13. Fredrik Elestedt

    Bob Lehmann Guest

    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

    "Marc Jennings" <> wrote in message
    news:...
    > Please tell me you're not serious. Please?
    >
    > On Fri, 26 Nov 2004 06:50:23 -0700, "Bob Lehmann"
    > <> wrote:
    >
    > >If they work, then why do you need to fix them?
    > >
    > >Bob Lehmann
    > >
    > >"Fredrik Elestedt" <> wrote in message
    > >news:...
    > >> 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
    > >>
    > >> "Bob Lehmann" <> wrote in message
    > >> news:%...
    > >> >> 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
    > >> >
    > >> > "Fredrik Elestedt" <> wrote in message
    > >> > news:%...
    > >> >> 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">
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >>
    > >>

    > >

    >
    Bob Lehmann, Nov 26, 2004
    #13
  14. Micael,

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

    // Fredrik

    "Micael Baerens" <> wrote in message
    news:eqPA$...
    > 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 ()
    >
    Fredrik Elestedt, Nov 27, 2004
    #14
  15. On Fri, 26 Nov 2004 13:22:32 -0700, "Bob Lehmann"
    <> wrote:

    >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?
    Marc Jennings, Nov 29, 2004
    #15
  16. Fredrik Elestedt

    fiur Guest

    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
    -----------------------------------------------------------------------
    Posted via http://www.codecomments.co
    -----------------------------------------------------------------------
    fiur, Aug 9, 2005
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. xyZed

    W3C validation site ltips?

    xyZed, Jun 26, 2003, in forum: HTML
    Replies:
    5
    Views:
    915
    Isofarro
    Jun 27, 2003
  2. William Tasso
    Replies:
    0
    Views:
    743
    William Tasso
    Aug 22, 2003
  3. Bruce W...1

    W3C validation questions

    Bruce W...1, Nov 8, 2003, in forum: HTML
    Replies:
    5
    Views:
    437
    Bruce W...1
    Nov 8, 2003
  4. Simon Meech

    W3c Validation for php files?

    Simon Meech, Dec 4, 2003, in forum: HTML
    Replies:
    16
    Views:
    3,448
    Mark Parnell
    Dec 8, 2003
  5. Frank
    Replies:
    9
    Views:
    1,566
    David Dorward
    May 3, 2004
Loading...

Share This Page