I want html, not xhtml from my aspnet controls

Discussion in 'ASP .Net Web Controls' started by j.madgwick@wiganmbc.gov.uk, Jan 3, 2007.

  1. Guest

    I'm confused. I've been trawling the web and can't find the
    answer...

    The background: I am working on a MCMS site with ASPNET 1.1.4322. We
    want the site to be written in standard compliant HTML that passes the
    W3C validator.

    The problem: ASPNET controls are generating HTML with xHTML
    self-closing tags. Eg. <img id="Image1" alt="" border="0" /> and <input
    type="hidden" name="__EVENTTARGET" value="" />

    A solution: I have read that you can use <xhtmlConformance
    mode="Legacy" /> in your web.config to control the type of HTML
    generated by an ASPNET control, but this is a feature of ASPNET 2.0, we
    are using 1.1.

    The confusion: From what I have read on the web, ASPNET 1.1 does *not*
    produce any xHTML code. Every article is about getting xHTML not
    getting rid of it! So, where are the closing tags coming from? Could
    it be part of a Service Pack or other windows/accessibility upgrade? I
    mention accessibility because I've noticed that it also puts a empty
    alt attribute into my img tags automatically too.

    Any information would be appreciated.
    Thanks,
    John.
     
    , Jan 3, 2007
    #1
    1. Advertising

  2. John,

    What is your problem exactly? You do not want the empty alt tags or
    closing tags?

    The empty alt tag is required if you specify a certain DTD for HTML.
    That is not just for XHTML. And the self closing tags... <br /> and
    <img /> will not cause legacy browsers to display the page incorrectly.
    It is not clear that the HTML validators will have a problem with them
    either. While this is an XHTML requirement, you may find that this is
    encouraged with the HTML 4 specification. You can see the official
    recommendation here...

    http://www.w3.org/TR/xhtml1/#guidelines

    Look at C.2. It explains to ease gradual migration from legacy HTML to
    XHTML the BR and IMG tags should include the self-closing feature.
    More here...

    http://en.wikipedia.org/wiki/HTML#Current_flavors_of_HTML
    http://en.wikipedia.org/wiki/HTML#Traditional_versus_XML-based_HTML

    I also wrote this last year which you may find useful.

    Why not XHTML Strict?
    http://brennan.offwhite.net/blog/2006/01/25/why-not-xhtml-11-strict/

    I also suggest keeping an eye on this website...

    http://alistapart.com/

    Brennan Stehling
    http://brennan.offwhite.net/

    wrote:
    > I'm confused. I've been trawling the web and can't find the
    > answer...
    >
    > The background: I am working on a MCMS site with ASPNET 1.1.4322. We
    > want the site to be written in standard compliant HTML that passes the
    > W3C validator.
    >
    > The problem: ASPNET controls are generating HTML with xHTML
    > self-closing tags. Eg. <img id="Image1" alt="" border="0" /> and <input
    > type="hidden" name="__EVENTTARGET" value="" />
    >
    > A solution: I have read that you can use <xhtmlConformance
    > mode="Legacy" /> in your web.config to control the type of HTML
    > generated by an ASPNET control, but this is a feature of ASPNET 2.0, we
    > are using 1.1.
    >
    > The confusion: From what I have read on the web, ASPNET 1.1 does *not*
    > produce any xHTML code. Every article is about getting xHTML not
    > getting rid of it! So, where are the closing tags coming from? Could
    > it be part of a Service Pack or other windows/accessibility upgrade? I
    > mention accessibility because I've noticed that it also puts a empty
    > alt attribute into my img tags automatically too.
    >
    > Any information would be appreciated.
    > Thanks,
    > John.
     
    Brennan Stehling, Jan 3, 2007
    #2
    1. Advertising

  3. Guest

    Hi Brennan,
    Thank-you for your response.
    My problem is my version of ASPNET 1.1 is producing xHTML (with
    self-closing tags) when I was expecting it to produce HTML (without
    self-closing tags).

    Originally, we were going to create the site in xHTML 1.0 Transitional,
    but we're using Microsoft CMS and can't get the bugger to produce
    valid xHTML. Therefore, we decided to go with HTML 4.0 Strict.
    Unfortunately, it has left us in a bit of limbo because tags produced
    by CMS are HTML and the ASPNET ones are xHTML. So, in the source code
    it looks as if we can't decide which one we want to use!

    You are right about the validator. It was not the self-closing tags
    causing the errors, so I guess this is a bit of a non-issue that I can
    live with now, but it is still annoying.

    We always use alt tags in our img tags so this was not the problem. I
    just mentioned it above because when I was doing some testing I
    wasn't expecting ASPNET to drop it in automatically. I thought it
    may be a clue towards a Service Pack that may have affected the output
    code.

    BTW: Nice article.

    Thanks again,
    John.
     
    , Jan 4, 2007
    #3
    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. Gary Nelson

    Upgrade from aspnet 1.1 to aspnet 2.0

    Gary Nelson, Oct 14, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    496
    Gary Nelson
    Oct 14, 2005
  2. Replies:
    7
    Views:
    674
    Juan T. Llibre
    Mar 23, 2007
  3. xhtml champs
    Replies:
    0
    Views:
    547
    xhtml champs
    Aug 1, 2011
  4. xhtml champs
    Replies:
    0
    Views:
    1,062
    xhtml champs
    Aug 2, 2011
  5. Brian Schuth
    Replies:
    0
    Views:
    288
    Brian Schuth
    Sep 8, 2003
Loading...

Share This Page