如何仅在不影响母版页的情况下将样式表添加到子页面?

时间:2016-09-26 09:14:35

标签: css asp.net master-pages

我尝试在项目的子页面中添加一些特殊功能,而不将其应用到母版页。因此我添加了一个样式表,现在它给了我几个警告,如下所示。

  

警告1更新JScript IntelliSense时出错:System \ JS \ materialize.js:预期的标识符,字符串或数字@ 1774:16 System \ agencyAdmin.aspx 1 1 Appeal

     

警告2验证(XHTML 1.0 Transitional):元素'链接'不能嵌套在元素中#td'。 System \ agencyAdmin.aspx 8 6上诉

     

警告4验证(XHTML 1.0 Transitional):属性'数据可折叠'不是元素的有效属性' ul'。 System \ agencyAdmin.aspx 14 33竞赛上诉

此外,当我执行程序并加载相关页面时,浏览器会显示错误,因为" Internet Explorer已停止工作"。
然后它显示以下错误。

  

JavaScript运行时错误:' $'未定义

我在本网站和其他一些网站上找到了答案。但对我来说没有用 以下是母版页标题部分中的代码



<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="CDDS_Master.master.cs" Inherits="ccs.CDDS_Master"  %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

    
    <asp:ContentPlaceHolder id="head" runat="server">
      <title></title>
    </asp:ContentPlaceHolder>
    <asp:ContentPlaceHolder ID="agency" runat="server">
    </asp:ContentPlaceHolder>
    
 <style type="text/css">
        .style1
        {
            height: 75; 
            width: 1024px;
            border-collapse: collapse; 
           
        }
        .styPageData
        {
        	 height:625px;
            width:934px;
      
            vertical-align:top;
        }
        .style4
        {
            height: 113px;
            width: 100%;
 
        }
        .style5
        {
            width: 925px;
            height: 103px;
        }
        .style7
        {
            width: 653px;
            height: 78px;
        }
        .style8
        {
            height: 78px;
            width: 245px;
        }
       
        .style9
        {
            width: 183px;
        }
        .styTreeWith
        {
            width: 200px;
        }
        .reportView
        {
            overflow:scroll;
        }
       
    </style>
    <link href="CSS/StyleSheet.css" rel="stylesheet" type="text/css" />
    
</head>
&#13;
&#13;
&#13;

以下是子页面中的代码

&#13;
&#13;
<%@ Page Title="" Language="C#" MasterPageFile="~/ccs.Master" AutoEventWireup="true"
    CodeBehind="agencyAdmin.aspx.cs" Inherits="ccs.agencyAdmin" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="agency" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <link href="CSS/materialize.css" rel="stylesheet" type="text/css" />
    <link href="CSS/materialize.min.css" rel="stylesheet" type="text/css"/>
    <script src="JS/materialize.js" type="text/javascript"></script>
    <script src="JS/materialize.min.js" type="text/javascript"></script>

    <div id="divCol" style="width: 100%; height: auto; float: left">
        <ul class="collapsible" data-collapsible="accordion">
            <li>
                <div class="collapsible-header">
                    <i class="material-icons">filter_drama</i>First</div>
                <div class="collapsible-body">
                    <p>
                        Lorem ipsum dolor sit amet.</p>
                </div>
            </li>
            <li>
                <div class="collapsible-header">
                    <i class="material-icons">place</i>Second</div>
                <div class="collapsible-body">
                    <p>
                        Lorem ipsum dolor sit amet.</p>
                </div>
            </li>
            <li>
                <div class="collapsible-header">
                    <i class="material-icons">whatshot</i>Third</div>
                <div class="collapsible-body">
                    <p>
                        Lorem ipsum dolor sit amet.</p>
                </div>
            </li>
        </ul>
    </div>

</asp:Content>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

use this code in child class



 <%@ Page Title="" Language="C#" MasterPageFile="~/ccs.Master" AutoEventWireup="true"
            CodeBehind="agencyAdmin.aspx.cs" Inherits="ccs.agencyAdmin" %>


        <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
        <link href="CSS/materialize.css" rel="stylesheet" type="text/css" />
            <link href="CSS/materialize.min.css" rel="stylesheet" type="text/css"/>
            <script src="JS/materialize.js" type="text/javascript"></script>
            <script src="JS/materialize.min.js" type="text/javascript"></script>

<style type="text/css">
        .style1
        {
            height: 75; 
            width: 1024px;
            border-collapse: collapse; 

        }
        .styPageData
        {
             height:625px;
            width:934px;

            vertical-align:top;
        }
        .style4
        {
            height: 113px;
            width: 100%;

        }
        .style5
        {
            width: 925px;
            height: 103px;
        }
        .style7
        {
            width: 653px;
            height: 78px;
        }
        .style8
        {
            height: 78px;
            width: 245px;
        }

        .style9
        {
            width: 183px;
        }
        .styTreeWith
        {
            width: 200px;
        }
        .reportView
        {
            overflow:scroll;
        }

    </style>
        </asp:Content>
        <asp:Content ID="agency" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


            <div id="divCol" style="width: 100%; height: auto; float: left">
                <ul class="collapsible" data-collapsible="accordion">
                    <li>
                        <div class="collapsible-header">
                            <i class="material-icons">filter_drama</i>First</div>
                        <div class="collapsible-body">
                            <p>
                                Lorem ipsum dolor sit amet.</p>
                        </div>
                    </li>
                    <li>
                        <div class="collapsible-header">
                            <i class="material-icons">place</i>Second</div>
                        <div class="collapsible-body">
                            <p>
                                Lorem ipsum dolor sit amet.</p>
                        </div>
                    </li>
                    <li>
                        <div class="collapsible-header">
                            <i class="material-icons">whatshot</i>Third</div>
                        <div class="collapsible-body">
                            <p>
                                Lorem ipsum dolor sit amet.</p>
                        </div>
                    </li>
                </ul>
            </div>

        </asp:Content>