如何将一个aspx中的Css样式导入另一个ASPX页面 [英] How to import Css styles in one aspx to another ASPX page

查看:113
本文介绍了如何将一个aspx中的Css样式导入另一个ASPX页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



如何在 aspx中包含 Css 样式到另一个 ASPX 页面,我的意思是,我在中有 css 样式aspx 页面,其中一些属性是动态加载的。所以让我知道如何做人。

喜欢这样的方式



通过会话变量,将背景图像应用于特定的div或body,就像这样方式...这里背景图片来自数据库。

<前lang =HTML>背景:url('<% =会话[ bg]。ToString()%>');





提前致谢!!!

解决方案

解决了我自己..



1.创建一个aspx页面(名称为site.css.aspx),没有代码隐藏页面(取消选中单独文件中的位置代码)

2.添加像休闲的内容



site.css.aspx名称包含



<%@ 页面语言=c# ContentType =text / css%>  
< script language =c# runat =server>
public string SearchButtonBgColor < span class =code-leadattribute> = #56687e;
public string SearchButtonHighlight < span class =code-leadattribute> = #9aa4b0;
public string SearchButtonShadow < span class =code-leadattribute> = #56687e;
public string rolloverColor < span class =code-leadattribute> = #996633;
public string lineColor < span class =code-leadattribute> = #a4b8df;
public string selectedChoiceBackgroundColor < span class =code-leadattribute> = #ffffff;

public string SearchButtonBgColorGreen = #6A9525;
public string SearchButtonHighlight1 < span class =code-leadattribute> = #95BC4D;
public string SearchButtonShadow1 < span class =code-leadattribute> = 416026 ;
public string textColor1 < span class =code-leadattribute> = 红色;

public string SearchButtonBgColorOrange = #DD9538;
public string SearchButtonBgColorRed < span class =code-leadattribute> = #F4584D;
public string SearchButtonBgColorBlue < span class =code-leadattribute> = #5A7D94;
public string SearchButtonBgColorPink < span class =code-leadattribute> = #D27ABC;
public string SearchButtonBgColorBrown < span class =code-leadattribute> = #C98888;
public string SearchButtonBgColorBluishGray < span class =code-leadattribute> = #6B869C;
public string BodyBgImage < span class =code-leadattribute> = ../ Images / In Bloom .JPG;
public string BodyBackColor < span class =code-leadattribute> = ;
public string textColor < span class =code-leadattribute> = #ffffff;
< / script >


@ font-face
{
font-family segoeui;
src url('../ Fonts / segoeui.otf')格式(opentype );
src url('../ Fonts / segoeui.eot');
src local('?'),url('../ Fonts / segoeui.woff')格式('woff'),url('../ Fonts / segoeui。 ttf')格式('truetype'),url('../Fonts / segoeui.svg')格式('svg');
font-重量 正常;
font-style 正常;
}

body
{
font-family segoeui;
颜色 <%= textColor%>;
职位 relative; / * padding-top:90px; * /
background-color 黑色;
/ * background-repeat:repeat;
background:url('<%= BodyBgImage%>'); * /


}
磁贴
{
width 30px;
display block;
margin 0px 0px 0px 0px;
text-decoration < span class =code-keyword> none;
padding < span class =code-keyword> 0px 0px 0px 0px;
text-align 中心;
}
a
{
text-decoration none;
}

tilesBackground
{
background 青色;
}
appstore
{
background-color #fff;
}

metro-section
{
width 960px !important ;
height 99%!important ;
position relative;
}

metro-section-title
{
font-size 20pt;
height 40px;
color black;
position relative;
}

hover-metro-section
{
border 1px solid green;
}

metro-se ctions
{
width 4000px;
position relative;
min-height 100%;
}

content
{
width 80%;
min-height 100%;
margin-top 50px;
margin-left 40px ;
}

body
{
溢出 auto;
宽度 100%;
min-height 100%;
}











3.然后将此文件链接到在哪里你想要使用这种风格。

在我给出的主页中这样的



就是这样。


您需要将CSS移动到css文件中,然后将css文件导入每个页面。


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!!!

解决方案

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";
</script>


@font-face
{
    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;
}

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

}
.tiles
{
    width: 30px;
    display: block;
    margin: 0px 0px 0px 0px;
    text-decoration: none;
    padding: 0px 0px 0px 0px;
    text-align: Center;
}
a
{
 text-decoration:none;
}

.tilesBackground
{
    background: Cyan;
}
.appstore
{
    background-color: #fff;
}

.metro-section
{
    width: 960px !important;
    height: 99% !important;
    position: relative;
}

.metro-section-title
{
    font-size: 20pt;
    height: 40px;
    color: black;
    position: relative;
}

.hover-metro-section
{
    border: 1px solid green;
}

.metro-sections
{
    width: 4000px;
    position: relative;
    min-height: 100%;
}

#content
{
    width: 80%;
    min-height: 100%;
    margin-top: 50px;
    margin-left: 40px;
}

#body
{
    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.


You need to move the CSS into a css file and then import the css file into each page.


这篇关于如何将一个aspx中的Css样式导入另一个ASPX页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆