我有一个基本的Css代码,我需要将它与我的Asp.Net母版页结合起来? [英] I Have A Basic Css Code And I Need To Combined It With My Asp.Net Master Page?

查看:76
本文介绍了我有一个基本的Css代码,我需要将它与我的Asp.Net母版页结合起来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的CSS代码



My CSS Code

body
{
background-color:#d0e4fe;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:"Times New Roman";
font-size:20px;
}







Asp.net主页面代码






Asp.net Master page code

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <asp:ContentPlaceHolder ID="Stylesheets" runat="server">
        <link rel="stylesheet" href="/css/StyleSheet.css" type="text/css" />
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>







我的Default.aspx代码






My Default.aspx Code

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Stylesheets" runat="server">
    <link rel="stylesheet" href="/css/StyleSheet.css" type="text/css" />
</asp:Content>









现在我想在默认的aspx中查看我的css文件,我需要将其添加到母版页...





now i want to view my css file in default aspx and i need to add it to the masterpage...

推荐答案

信息不清楚。据我所知,你正在向母版页添加一个CSS文件



让我告诉你一件事,当你添加CSS文件到母版页,这些样式由子页面自动继承,并反映在它们上。
Information not clear. As far as I understand, you are adding one CSS file to the Master Page.

Let me tell you one thing, when you add CSS file to the Master Page, those styles are automatically inherited by the Child Pages and also gets reflected on them.


Refer Tadit 的解决方案。然后,如果您打算添加一些特定于内容页面的附加CSS,请在母版页的头部部分添加ContentPlaceHolder,并在内容页面中引用该ContentPlaceholder以添加另一个CSS文件。这适用于页面特定的CSS。已经可以看到你正在尝试在共享的标记代码中做类似的事情。
Refer Tadit's Solution. Then if you intend to add some additional CSS which is specific for Content Pages , Add a ContentPlaceHolder in the Head section of the Master Page and refer that ContentPlaceholder in the Content Page to add another CSS file.This applies Page specific CSS . Already can see you are trying to do something like that in the Markup code shared.


这篇关于我有一个基本的Css代码,我需要将它与我的Asp.Net母版页结合起来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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