Click here to Skip to main content
15,741,947 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
Hi everyone,

How to include Css styles in aspx to another ASPX page, i mean, i have css styles in aspx page, in which some properties are loaded dynamically. so let me know how to do guys.
like this way

Through session variable, applying background image to particular div or body like this way... here background image comes from database.
background: url('<%=Session["bg"].ToString() %>');

Thanks in advance!!!
Dholakiya Ankit 12-Sep-13 8:27am    
?? loaded dyanmically? give me example
Sanjeev Alamuri 12-Sep-13 8:31am    
Through session variable, applying background image to particular div or body like this way... here background image comes from database.

background: url('<%=Session["bg"].ToString() %>');
Can't you use the same method in other pages?
Sanjeev Alamuri 12-Sep-13 12:03pm    

Solved myself..

1. Create one aspx page(with "site.css.aspx" as name) without codebehind page (uncheck place code in seperate file)
2. Add content like as fallows

site.css.aspx name contains

<%@ Page Language="c#" ContentType="text/css" %>
<script language="c#" runat="server">
    public string SearchButtonBgColor = "#56687e";
    public string SearchButtonHighlight = "#9aa4b0";
    public string SearchButtonShadow = "#56687e";
    public string rolloverColor = "#996633";
    public string lineColor = "#a4b8df";
    public string selectedChoiceBackgroundColor = "#ffffff";

    public string SearchButtonBgColorGreen = "#6A9525";
    public string SearchButtonHighlight1 = "#95BC4D";
    public string SearchButtonShadow1 = "#416026 ";
    public string textColor1 = "Red";

    public string SearchButtonBgColorOrange = "#DD9538";
    public string SearchButtonBgColorRed = "#F4584D";
    public string SearchButtonBgColorBlue = "#5A7D94";
    public string SearchButtonBgColorPink = "#D27ABC";
    public string SearchButtonBgColorBrown = "#C98888";
    public string SearchButtonBgColorBluishGray = "#6B869C";
    public string BodyBgImage = "../Images/In Bloom.jpg";
    public string BodyBackColor = "";
    public string textColor = "#ffffff";

    font-family: segoeui;
    src: url('../Fonts/segoeui.otf') format("opentype");
    src: url('../Fonts/segoeui.eot');
    src: local('?'), url('../Fonts/segoeui.woff') format('woff'), url('../Fonts/segoeui.ttf') format('truetype'), url('../Fonts/segoeui.svg') format('svg');
    font-weight: normal;
    font-style: normal;

    font-family: segoeui;
    color: <%= textColor %>;
    position: relative; /*padding-top: 90px;*/
    background-color: Black;
    /*background-repeat: repeat;
    background:url('<%= BodyBgImage %>');*/

    width: 30px;
    display: block;
    margin: 0px 0px 0px 0px;
    text-decoration: none;
    padding: 0px 0px 0px 0px;
    text-align: Center;

    background: Cyan;
    background-color: #fff;

    width: 960px !important;
    height: 99% !important;
    position: relative;

    font-size: 20pt;
    height: 40px;
    color: black;
    position: relative;

    border: 1px solid green;

    width: 4000px;
    position: relative;
    min-height: 100%;

    width: 80%;
    min-height: 100%;
    margin-top: 50px;
    margin-left: 40px;

    overflow: auto;
    width: 100%;
    min-height: 100%;

3. and then link this file to where ever u want to use this styles.
in master page i had given like this

thats it.
Share this answer
You need to move the CSS into a css file and then import the css file into each page.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900