Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ASP.NET CSS Postback Stripped???

Posted on 2010-11-13
6
Medium Priority
?
711 Views
Last Modified: 2012-05-10
I have an ASP.NET master page  that contains a header and footer enclosed in a table.  The master page contains a link to my CSS file which my header login link uses for a roll-over button.  I've setup CSS as follows:

a.ButtonTest:link
{
    background-image: url(../images/SimpleButtonUp.gif);
    background-color: transparent;
    color: White;
    cursor: pointer;
    width: 80px;
    height: 23px;
}

a.ButtonTest:hover
{
    background-image: url(../images/SimpleButtonDown.gif);
}

This works perfectly upon loading my home page but navigating anywhere else results in the background image being stripped from the CSS.  The relative path to the background image is EXACTLY the same as any of the pages I navigate to.

What's going here?  How do I make my master page CSS survive posting?
0
Comment
Question by:Phil5780
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 34129195
Are your pages in the same physical location?
(../images/SimpleButtonUp.gif) is relative path.
Make sure all pages that use this css are on the same folder.
0
 

Author Comment

by:Phil5780
ID: 34129275
Ok, after further trial and error I find that my CSS in the sheet (just the markup shown above) gets ignored after postback. The page I begin with and the page I navigate to are in the same relative location.  The postback is breaking my CSS, how do I fix this?
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 34129390
try to specify the absolute path


background-image: url(/ParentFolder/images/SimpleButtonUp.gif);
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 7

Expert Comment

by:armchang
ID: 34129918
hi,

There maybe a problem in where you put your link to the CSS and might be causing you the break. You can check if you have done the same as this:

<head runat="server">

  <style type="text/css" media="all">
    @import "styles/styles.css";
  </style>
  
</head> 

Open in new window

0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 34132688
Can you post your css file markup (How are you adding it to master page?)
e.g in
 <head runat="server">

    <link href="Styles/myCssSample.css" rel="stylesheet" type="text/css" />  
</head>  
0
 

Author Closing Comment

by:Phil5780
ID: 34160521
You were right, my relative path was wrong.  No everything work just fine.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question