locked
Adapter causes page to fail W3C validation check RRS feed

  • Question

  • User-353626846 posted

    I'm using the CSS Friendly Control Adapter in my project to make my treeview W#C compliant.  It's done that nicely, however, when I run the page through the validator.w3.org checker, it complains about the webresource links for the Adapter related javascript.  The errors are:
    ===============================================================

    Line 34, Column 275: cannot generate system identifier for general entity "t".

    …yxepBMgsCRuhTa5CYBsXeTRJyNIlb5PBgss0&t=633481763425116282" type="text/css" re
    Line 34, Column 275: general entity "t" not defined and no default entity.
    …yxepBMgsCRuhTa5CYBsXeTRJyNIlb5PBgss0&t=633481763425116282" type="text/css" re

    Line 34, Column 276: reference not terminated by REFC delimiter.

    …xepBMgsCRuhTa5CYBsXeTRJyNIlb5PBgss0&t=633481763425116282" type="text/css" rel
    Line 34, Column 276: reference to external entity in attribute value.
    …xepBMgsCRuhTa5CYBsXeTRJyNIlb5PBgss0&t=633481763425116282" type="text/css" rel
    Line 34, Column 276: reference to entity "t" for which no system identifier could be generated.
    …xepBMgsCRuhTa5CYBsXeTRJyNIlb5PBgss0&t=633481763425116282" type="text/css" rel
     
    Line 34, Column 329: document type does not allow element "link" here.
    …282" type="text/css" rel="stylesheet"></link>
     
    Line 34, Column > 80: XML Parsing Error: EntityRef: expecting ';'.
    …zhCXwxJFkVObe4FOM7Ph-rEFk7W9J1s86X4uzJN9gtwCzCUPdSyxTAI_t2sGDJx9InIpFPfQjMA2&…
     
    ===============================================================
     
    One of the errors is that the <link> tag is not allowed where it is - it must be in the <head> tag.  The Adapter isn't rendering it where it should.  I don't know if the other errors would be solved by moving the tag to be inside the <head>, but I suspect not.
     
    Is there a way to get around this ?  The whole reason for using the Adapters is to help me with W3C compliance, and it seems to be responsible for failing the W3C validation.

     
    Wednesday, June 4, 2008 2:32 AM

All replies

  • User-1754643693 posted

    OK, yesterday I managed to get around this for the main menu and hopefully these instructions will help:

    1. download the source zip file.
    2. Open the project and open MenuAdapter.cs
    3. Goto Line 77 (should start "string cssTag = ")
    4. Insert the line below to change the ampersand character to the HTML code
     

    filePath = filePath.Replace("&", "&amp;");
     
    5. Goto Line 79 (should start "if (!Page.ClientScript"
    6. Insert the lines below to create the header tag
     
    HtmlLink link = new HtmlLink();
    link.Attributes.Add("type", "text/css");
    link.Attributes.Add("rel", "stylesheet");
    link.Attributes.Add("href", Page.ResolveUrl(filePath));

                    
    7. Goto Line 84 (should start "Page.ClientScript")
    8. Replace this line with the one below to write the page header 
     

    Page.Header.Controls.Add(link);


    9. Goto Line 94 (should start "string cssTag = ")
    10. Insert the line below to change the ampersand character to the HTML code
     

    filePath = filePath.Replace("&", "&amp;");
     
    11. Goto Line 96 (should start "if (!Page.ClientScript"
    12. Insert the lines below to create the header tag
     
    HtmlLink link = new HtmlLink();
    link.Attributes.Add("type", "text/css");
    link.Attributes.Add("rel", "stylesheet");
    link.Attributes.Add("href", Page.ResolveUrl(filePath));
                    
    13. Goto Line 84 (should start "Page.ClientScript")
    14. Replace this line with the one below to write the page header
     
    Page.Header.Controls.Add(link);

     

    Looking throught the treeview.cs file you need to be looking to do this around the 220 line number.  There only appears to be the one occurance that needs updating.  Once done, compile the DLL and refresh your website

    Hope that helps a bit

    Wednesday, July 9, 2008 3:23 AM
  • User-319574463 posted

     Good spotting sf-mandelbug.  Hopefully the support team will pick up your fix.

    Wednesday, July 9, 2008 4:18 AM
  • User575409785 posted

    Yes, good catch--thanks.

    Now, could you perhaps answer a really bone-headed question for me?

     I'm using VWD Express 2008. How do I "compile the dll"? Do I have to use csc.exe? If so, what's the correct syntax?

     Sorry if this is a really obvious question. I'm still very new to ASP.NET and have only recently stumbled across the CSSFriendly Adapters.

     

    Thanks!

    Tuesday, July 22, 2008 5:35 PM
  • User-1754643693 posted

     Unfortunately I do not know the express products so would be unable to answer.  All I know is that within Visual Studio 2005 its a matter of building the application (compiling the DLL).

     

    Wednesday, July 23, 2008 3:44 AM
  • User575409785 posted

    Hi, again!

    I couldn't find an equivalent to the lines you referenced in the MenuAdapter.vb file that I was using -- I think the file was created when I made a new web site using the VSI download for Release 1.0 -- anyway, in THAT version of the MenuAdapter.vb, I found what appeared to be writing the text for the <a> or <span> and modified that:

     There's a BuildItem sub, and line 187 was:

                        writer.Write(item.Text)

    So I inserted this before it:

              item.Text = Replace(item.Text, "&", "&amp;")
                        writer.Write(item.Text)

     And now my pages validate!!!!

     

    Thanks for getting me started in the right direction.

     

     

    Friday, July 25, 2008 7:56 PM
  • User-1754643693 posted

    Fantastic, well done on getting the VSI converted :-)

    Monday, July 28, 2008 2:42 AM
  • User-590252356 posted

    Thanks sf-mandelbug, it resolved the HTML validation problem

    However when I used a <asp:Menu ID="NavigationList" runat="server" DataSourceID="Sitemap" Orientation="Horizontal" /> control on the page it gives a javascript error:

    Line:2
    Char:1
    Error:Syntax error
    Code:0

    Anyone can help?

    Wednesday, March 11, 2009 1:19 PM