AZGroups.com

Bringing together Arizona Technology Users And Enhancing the Careers of Developers
Welcome to AZGroups.com Sign in | Join | Help
in Search

XHTML & CSS

Last post 07-01-2006, 12:06 PM by tracker1. 2 replies.
Sort Posts: Previous Next
  •  06-30-2006, 9:47 PM 448

    XHTML & CSS

    Okay, adding this thread to discuss XHTML & CSS isues with ASP.Net

    First step is to be able to pass the w3c validator at:
    http://validator.w3.org/ 

    Step 1: USE XHTML 1.1 as your target type...

    Step 2: Add the App_Browsers folder to your web project, and insert a new file named w3c_validator.browser to it... you can download it here..
    http://www.theroughnecks.com/download/asp-net-2.0-w3cvalidator-browsertype.zip

    Step 3: Create a small wrapper for System.Web.UI.HtmlControls.HtmlForm
    protected override void RenderAttributes(HtmlTextWriter output) {
        StringBuilder sb = new StringBuilder();
        StringWriter sw = new StringWriter(sb);
       
    HtmlTextWriter tw = new HtmlTextWriter(sw);
       
    base.RenderAttributes(tw);

       
    // create custom attributes
       
    output.Write(sb.ToString().Replace(" name=\"aspnetForm\"", ""));
    }

    You will probably want to do a designer for this, honestly, I'm not so good with that, if someone impliments an HtmlForm based control like this, with a designer, please email it to me.. :)

  •  07-01-2006, 12:06 PM 449 in reply to 448

    Re: XHTML & CSS

    Now that you can get the validator to have the proper tagging, thanks to the browser file, and the control based on HtmlForm.

    Second stage is to handle style sheets.  You should avoid using a <link> or <style> tag in the body, always... I prefer to use ONLY link tags in the page header.

    TIP 1: If you are using master pages, and want to add a tag to the head section in ASP.Net 2.

    Page.Headers.Add(new LiteralControl(String.Format(
        @"<link rel=""stylesheet"" type=""text/css"" href=""{0}.css"" />",
        Page.Request.Path
    ));


    This will allow you to have a MyPage.aspx with a css for just that page with MyPage.aspx.css ...  I actually have been using my master page to check for the existance of the css, and add the link tag if it exists... I also check for _ with Request.Browser.Browser.ToLower() as well.  This allows me to have my general link/stylesheet, with custom, or tweaks per browser, or page.

    You can also use the IE conditional comment syntax for IE browsers.
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie.css" />
    <![endif]-->
    As an example.  you can google for IE conditional comment for more information on this, such as syntax.  Since IE7 will correct a lot of issues, and Opera 9 corrected most of their issues.. IE6 and below will probably be your only real concern in the next year.  You will likely have a general style, with a conditional comment style for IE6.

    Hope this helps as a starting point into using css... if you want more information on CSS in general, would look at "Cascading Style Sheets: The Definitive Guide" from O'Reilly Press, which is now in it's second edition.
    http://www.amazon.com/gp/product/0596005253/

    If you are curious as to how far CSS can go with a site, feel free to check out the CSS Zen Garden, or my site (Roughneck BBS).
  •  07-01-2006, 12:06 PM 450 in reply to 448

    Re: XHTML & CSS

    Now that you can get the validator to have the proper tagging, thanks to the browser file, and the control based on HtmlForm.

    Second stage is to handle style sheets.  You should avoid using a <link> or <style> tag in the body, always... I prefer to use ONLY link tags in the page header.

    TIP 1: If you are using master pages, and want to add a tag to the head section in ASP.Net 2.

    Page.Headers.Add(new LiteralControl(String.Format(
        @"<link rel=""stylesheet"" type=""text/css"" href=""{0}.css"" />",
        Page.Request.Path
    ));


    This will allow you to have a MyPage.aspx with a css for just that page with MyPage.aspx.css ...  I actually have been using my master page to check for the existance of the css, and add the link tag if it exists... I also check for _ with Request.Browser.Browser.ToLower() as well.  This allows me to have my general link/stylesheet, with custom, or tweaks per browser, or page.

    You can also use the IE conditional comment syntax for IE browsers.
    <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="all-ie.css" />
    <![endif]-->
    As an example.  you can google for IE conditional comment for more information on this, such as syntax.  Since IE7 will correct a lot of issues, and Opera 9 corrected most of their issues.. IE6 and below will probably be your only real concern in the next year.  You will likely have a general style, with a conditional comment style for IE6.

    Hope this helps as a starting point into using css... if you want more information on CSS in general, would look at "Cascading Style Sheets: The Definitive Guide" from O'Reilly Press, which is now in it's second edition.
    http://www.amazon.com/gp/product/0596005253/

    If you are curious as to how far CSS can go with a site, feel free to check out the CSS Zen Garden, or my site (Roughneck BBS).
  • View as RSS news feed in XML
    Powered by Community Server, by Telligent Systems