DataList not using <BODY> tag settings


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: DataList not using <BODY> tag settings

  1. #1
    Join Date
    Nov 2003
    Location
    Austin, Texas
    Posts
    59

    DataList not using <BODY> tag settings

    I have a pretty simple web page where I have pushed the content into XML and I load the page using a DataList. However, when I load XML that contains a hyperlink, the datalist does not use the settings from the <BODY> tag. I am setting the link, vlink, and alink colors in the body tag.

    For example, here is my body tag.

    Code:
    <body text="#000000" link="#ab0b38" vlink="#ab0b38" alink="#ab0b38">
    The datalist renders part of the XML as follows...

    HTML Code:
    ... attract <A href="XXXX.aspx">people</A>, and to put...
    The problem is that since the hyperlink is being created by the datalist, it is ignoring the body tag, which in this case should be coloring the links a sort of red color. What is actually happening, is that the color goes back to the default blue as if I had never set them in the body tag at all.

    To prove this is not my code and that this is something that the datalist is doing, if you save the source of the rendered page in IE to an HTML file, and then open that file in IE, the colors come out correct, as the links ARE using the body tag settings.

    So, how do you get the datalist to STOP ignoring the body tag? Maybe there is another approach that I have not considered.

    Any suggestions would be very much appreciated.

    Thanks,
    Greg Rothlander
    PBSI
    Last edited by jrothlander; 04-27-2005 at 11:07 AM.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You might try defining your hyperlink styles in CSS, rather than in the BODY tag.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Nov 2003
    Location
    Austin, Texas
    Posts
    59
    I originally looked at that, but I did not see any option to define the hyperlink styles in the CSS. How do you define a style with a given color for link, vlink, and alink, in a CSS? What attributes do you use? I'm using .Net and I cannot see a way to set this up in a CSS.

    Here is the basic idea. How do you do this in a CSS?

    ColorOption1
    {
    link:blue;
    alink:blue;
    vlink:blue:
    }

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Nov 2003
    Location
    Austin, Texas
    Posts
    59
    Phil,

    Thanks for all the help, but that is not exactly what I was looking for. I think that what you are getting at is that I can control the <A> tag properties like this. That's not exactly what I want to do. The reason it is not is because each web page in my app has a unique color setting for each of these, and if I control it via the CSS, I have to create a unique CSS for each web page. That's a lot of extra work just to control the hyperlink colors.

    I started off going this route and realized that I could not create a CSS class that defined the <A> tags hyperlink colors, and that I could only create the <A> tags color for the whole CSS. What I need is a way to change the hyperlink colors for each page that I am on. I want the hyperlinks to match the color scheme of each page. Lets say that you have two pages. One uses a blue color scheme and the other uses a green color scheme. I want the blue page to have blue hyperlinks and the green page to have green hyperlinks... it really cleans up the text.

    The only way that I have been able to get this to work is to control this via the <BODY> tag. If I could do soemthing like <BODY class="BlueLinks"> then I would be set. However, the ONLY other way to do this would be to create one CSS per page and I think that's overkill.

    I just figured out what my problem was. If you set the hyperlink colors in the <BODY> tag and then they are also set in the CSS, the CSS overwrites them! So, I was able to get the datalist to allow my <BODY> tag to control the hyperlink colors, but I was really hoping to push this stuff our into the CSS, as I do not like hardcoding the colors in the <BODY> tag.

    I really appreciate your help and sending me the link that shows you how to set up the <A> tag properties in the stylesheet. If you have any ideas on how to get a CSS class (vs. an element) to control this, please let me know.

    Thank again,
    Greg Rothlander
    Last edited by jrothlander; 04-27-2005 at 03:10 PM.

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    I don't understand why CSS is more work than the BODY tag? You can specify CSS styles in the page; it doesn't have to be in a .css file. Simply include the desired styles between <style> tags in the <HEAD> section of each page.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Aug 2004
    Posts
    64
    Quote Originally Posted by jrothlander
    If I could do soemthing like <BODY class="BlueLinks">
    You can do this.

    Code:
    body.BlueLinks a
    {
        color: blue;
    }
    This means that all A tags inside a BODY tag with class BlueLinks will have this style.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center