Solved

ASP.NET CSS Postback Stripped???

Posted on 2010-11-13
6
700 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 500 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
Independent Software Vendors: 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!

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

710 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