Solved

ASP.NET CSS Postback Stripped???

Posted on 2010-11-13
6
693 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
6 Comments
 
LVL 35

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:adilkhan
ID: 34129390
try to specify the absolute path


background-image: url(/ParentFolder/images/SimpleButtonUp.gif);
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 35

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now