Solved

ASP.NET CSS Postback Stripped???

Posted on 2010-11-13
6
706 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

627 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