Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. css file not getting applied by asp.net page

css file not getting applied by asp.net page

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-netwpfhelp
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 3919049
    wrote on last edited by
    #1

    I'm getting a weird error. I have a css class and I dragged the reference onto the aspx. The compile-time page is recognizing the reference to the styles in the css because when I remove the css reference from the aspx the page displays squiggly lines under the CssClass references with a tooltip "cannot be found". However, when I run the page the css classes aren't getting applied. Also weird - when I copy the css class definitions from the css file into a tag in the <head> variable of my page the css classes DO get applied. I can't figure out why my css classes aren't getting applied at runtime even though the references appear to check out at compile time. Any ideas?</x-turndown>

    P S J 3 Replies Last reply
    0
    • M Member 3919049

      I'm getting a weird error. I have a css class and I dragged the reference onto the aspx. The compile-time page is recognizing the reference to the styles in the css because when I remove the css reference from the aspx the page displays squiggly lines under the CssClass references with a tooltip "cannot be found". However, when I run the page the css classes aren't getting applied. Also weird - when I copy the css class definitions from the css file into a tag in the <head> variable of my page the css classes DO get applied. I can't figure out why my css classes aren't getting applied at runtime even though the references appear to check out at compile time. Any ideas?</x-turndown>

      P Offline
      P Offline
      PSK_
      wrote on last edited by
      #2

      Have you checked the url of css file in the generated page source. It seems to me that the path of the css file is incorrect. Try using ResolveClientUrl to set the css url.

      <%=ResolveClientUrl("~/css/default.css")%>

      WWW, WCF, WWF, WPF, WFC .... WTF

      1 Reply Last reply
      0
      • M Member 3919049

        I'm getting a weird error. I have a css class and I dragged the reference onto the aspx. The compile-time page is recognizing the reference to the styles in the css because when I remove the css reference from the aspx the page displays squiggly lines under the CssClass references with a tooltip "cannot be found". However, when I run the page the css classes aren't getting applied. Also weird - when I copy the css class definitions from the css file into a tag in the <head> variable of my page the css classes DO get applied. I can't figure out why my css classes aren't getting applied at runtime even though the references appear to check out at compile time. Any ideas?</x-turndown>

        S Offline
        S Offline
        Sandeep Mewara
        wrote on last edited by
        #3

        Member 3919049 wrote:

        I can't figure out why my css classes aren't getting applied at runtime even though the references appear to check out at compile time.

        At times, it happen that it is fine during compile time but when you publish it, the path is little different and thus you code is unable to refer it. Looks like the same with you. Using viewsource of page, check where is the stylesheet being referred. Is the location correct based on your project hierarchy. If you are unable to resolve the path in deisgner, you can check the value of it on server side, using the same URL. You can also, set the URL of CSS via codebehind. Refer: Resolving Paths in a Multi-Folder WebSite[^]

        1 Reply Last reply
        0
        • M Member 3919049

          I'm getting a weird error. I have a css class and I dragged the reference onto the aspx. The compile-time page is recognizing the reference to the styles in the css because when I remove the css reference from the aspx the page displays squiggly lines under the CssClass references with a tooltip "cannot be found". However, when I run the page the css classes aren't getting applied. Also weird - when I copy the css class definitions from the css file into a tag in the <head> variable of my page the css classes DO get applied. I can't figure out why my css classes aren't getting applied at runtime even though the references appear to check out at compile time. Any ideas?</x-turndown>

          J Offline
          J Offline
          Jamil Hallal
          wrote on last edited by
          #4

          Hi, Have you ever tried to refresh the page , sometimes the css + js files are cached, Ctrl + F5 could help i faced this issue when trying to add new css classes to the stylesheet file and fixed it by refreshing the page

          Regards, Jamil

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups