SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Uh-oh... CSS and ASP.NET

    Dear everyone,

    First of all, I want to underscore the fact that this little thread covers an issue spanning both ASP.NET and CSS. Since it concerns CSS mainly, however, it is posted in the CSS sub-forum.
    So. Here's the background informatio: in my script, entitled "default.aspx" for simplicity's sake, I use ASP.NET's fancy little "Response.WriteFile();" command to include the contents of another ASP.NET file containing my CSS style. I then use the "id" attribute of XHTML to apply the formatting.
    The actual problem is as follows. ASP.NET also uses the "id" attribute, and it uses it to manipulate objects dynamically. Since therefore you cannot have more than one object with the same ID, you have to use the "class" attribute to apply formatting, and stick with the "id" attribute for ASP.NET.
    However, here a nasty little corollary of the venerable Murphy's Law kicks in. For some unknown reason, with the style included in the "head" tag via ASP.NET, the "class" attribute refuses to apply formatting. Any ideas?
    Thanks for your help.

    Compuwhiz7

  2. #2
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like there's a problem in the output. Any chance you could show us the generated html source (view source in a browser, rather than the "raw" file on the server)

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    I believe that you have to use "cssClass" on server controls in ASP.NET rather than "class", like so:
    Code:
    <asp:label id="myLabel1" cssClass="strongpurple" />
    And that label would turn into something like this:
    HTML Code:
    <span id="myLabel1" class="strongpurple">Hello</span>

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear everyone,

    To answer Blufive's question, the code is as follows:

    Code:
    <%@ Page Language="C#" %>
    <html>
    <head>
    <title>Really Important Text Here</title>
    <% Response.WriteFile("/aspdotnet/styling.aspx"); %>
    </head>
    <body>
    <div id="page">
    <img id="header_image" src="/jpg/header.jpg" />
    <div id="header_text">Home</div>
    <img id="sidebar_image" src="/jpg/sidebar.jpg" />
    <div id="sidebar_content"></div>
    <div id="content_frame">
    <div id="heading">Welcome</div>
    <div id="paragraph">
    Even more important text here...
    </div>
    </div>
    </div>
    </body>
    </html>
    And in regard to want V. Garcia said: I tried using the "cssclass" attribute, but here's the problem: so far, none of my elements are ASP.NET elements. The only part where ASP.NET comes into play is in using the "Response.WriteFile" function that you'll notice in my included code.

    Compuwhiz7

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Apr 2003
    Posts
    4,095
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dear everyone,

    Never mind... . It turns out that the problem was that I was using "#" in front of my CSS styles instead of ".", so the "class" attribute couldn't access them.

    Compuwhiz7


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •