RenderBeginTag() output not XHMTL compliant

Discussion in 'ASP .Net' started by MatsL@newsgroups.nospam, Oct 6, 2006.

  1. Guest

    Hi,
    This is seriously driving me crazy, could anyone explain to me why
    neither of these doesn't produce XHTML compliant output (it is being
    called in Render() btw):

    output.WriteLine("<img src=\"" + vars["{$baseUrl}"] + " />");

    output.AddAttribute(HtmlTextWriterAttribute.Src,
    (string)vars["{$baseUrl}"]);
    output.RenderBeginTag(HtmlTextWriterTag.Img);
    output.RenderEndTag();

    They both produce the same output:
    <img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974">

    What I want is this:
    <img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974" />

    Is there some setting that needs to be set or anything like that?


    Thanks in advance!

    Best regards,
    Mats Lycken
     
    , Oct 6, 2006
    #1
    1. Advertising

  2. the fragment is valid, but what is the parent element?

    -- bruce (sqlwork.com)

    <> wrote in message
    news:%...
    > Hi,
    > This is seriously driving me crazy, could anyone explain to me why neither
    > of these doesn't produce XHTML compliant output (it is being called in
    > Render() btw):
    >
    > output.WriteLine("<img src=\"" + vars["{$baseUrl}"] + " />");
    >
    > output.AddAttribute(HtmlTextWriterAttribute.Src,
    > (string)vars["{$baseUrl}"]);
    > output.RenderBeginTag(HtmlTextWriterTag.Img);
    > output.RenderEndTag();
    >
    > They both produce the same output:
    > <img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974">
    >
    > What I want is this:
    > <img src="/ChartImages/AllChart_68.jpg?KxRx=0x0974" />
    >
    > Is there some setting that needs to be set or anything like that?
    >
    >
    > Thanks in advance!
    >
    > Best regards,
    > Mats Lycken
     
    bruce barker \(sqlwork.com\), Oct 6, 2006
    #2
    1. Advertising

  3. Is "output" an HtmlTextWriter or an XhtmlTextWriter? (what it is rendering
    is proper HTML but not XHTML, similar to how <input> works)
     
    Keith Patrick, Oct 6, 2006
    #3
  4. Hello Mats,

    As for the control/element rendering code, where did you call them? Are you
    using these code to output some child html element in your custom webserver
    control?

    As for the XHTML content producing, ASP.NET 2.0 provide three Conformance
    mode

    **Legacy (which is similar to how markup was rendered in previous versions
    of ASP.NET)

    **Transitional (XHTML 1.0 Transitional)

    **Strict (XHTML 1.0 Strict)

    And the default one "Transitional" will help render most controls as XHTML
    conformed output though it still includes a few exceptions. And if you set
    the conformance mode to "Strict", it will force to page to output xhtml
    content that conform to XHTML 1.0 Strict standard. You can get more
    information about the ASP.NET 2.0 xhtml confromance setting in the
    following MSDN reference:

    #ASP.NET and XHTML
    http://msdn2.microsoft.com/en-us/library/exc57y7e.aspx

    for your problem here, I've just performed some test on my local side
    through a custom webserver control, it seems that the output is correctly
    XHTML conformed (set ASP.NET xhtml conformance as "Transitional" and use
    IE6 to visit the page). Here is my test code:

    ==========================
    protected override void RenderContents(HtmlTextWriter output)
    {
    output.AddAttribute("id", "divxhtml");
    output.RenderBeginTag(HtmlTextWriterTag.Div);


    output.WriteLine("<img
    src=\"http://www.asp.net/i/www_asp_net_logo.gif\" />");

    output.Write(Text );


    output.AddAttribute(HtmlTextWriterAttribute.Src,
    "http://www.asp.net/i/www_asp_net_logo.gif");
    output.RenderBeginTag(HtmlTextWriterTag.Img);
    output.RenderEndTag();


    output.RenderEndTag();
    }

    ==========================

    and the web.config file just contains the following XHTML conformance
    setting(the default value):

    <xhtmlConformance mode="Transitional"/>


    Please feel free to let me know if there is anything I missed or if you
    have any other particular settings in your application.



    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================



    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Oct 9, 2006
    #4
    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. BT
    Replies:
    4
    Views:
    564
    Jan Faerber
    Feb 14, 2005
  2. shapper

    RenderBeginTag

    shapper, Dec 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,670
    shapper
    Dec 28, 2006
  3. Matthias Braun

    XHMTL and CSS Problem

    Matthias Braun, Jan 31, 2010, in forum: HTML
    Replies:
    14
    Views:
    1,299
    Matthias Braun
    Feb 1, 2010
  4. Florian Weimer

    Tunneling own XML content in XHMTL etc.

    Florian Weimer, Jan 24, 2011, in forum: XML
    Replies:
    6
    Views:
    1,019
    Florian Weimer
    Feb 5, 2011
  5. Henri
    Replies:
    1
    Views:
    382
    Henri
    Jul 13, 2004
Loading...

Share This Page