Asp.net

此頁面缺少要添加的 CSS 樣式錶鍊接所需的 HtmlHead 控制項。請添加 <head runat=‘server’ />

  • September 19, 2016

我有頁面並添加了 Ajax 擴展,但它給我拋出了錯誤

我正在使用母版頁,所以這個頁面沒有&lt;head&gt;

頁面程式碼

&lt;%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;

&lt;%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" runat="server" %&gt;


&lt;asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"&gt;

   &lt;table style="width: 100%"&gt;
   &lt;tr&gt;
       &lt;td colspan="5" style="text-align: center; height: 20px;"&gt;Search &lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td style="text-align: center; height: 20px;"&gt;Ticket number&lt;/td&gt;
       &lt;td style="text-align: center; height: 20px;"&gt;Client name&lt;/td&gt;
       &lt;td style="text-align: center; height: 20px;"&gt;Address&lt;/td&gt;
       &lt;td style="text-align: center; height: 20px;"&gt;Assigned to&lt;/td&gt;
       &lt;td style="text-align: center; height: 20px;"&gt;Date&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td style="width: 157px"&gt;
           &lt;asp:TextBox ID="txt_incID" runat="server" Width="146px"&gt;&lt;/asp:TextBox&gt;
       &lt;/td&gt;
       &lt;td&gt;
           &lt;asp:TextBox ID="txb_ClientName" runat="server" Width="146px"&gt;&lt;/asp:TextBox&gt;
       &lt;/td&gt;
       &lt;td&gt;
           &lt;asp:DropDownList ID="ddl_Address" runat="server" Width="146px" DataSourceID="Ds_address" DataTextField="StrName" DataValueField="StrID"&gt;
               &lt;asp:ListItem Value="null"&gt;&lt;/asp:ListItem&gt;
           &lt;/asp:DropDownList&gt;
       &lt;/td&gt;
       &lt;td&gt;
           &lt;asp:DropDownList ID="ddl_EmpID" runat="server" Width="146px" DataSourceID="DS_Employee" DataTextField="LastName" DataValueField="EmpID"&gt;
               &lt;asp:ListItem Value="null"&gt;&lt;/asp:ListItem&gt;
           &lt;/asp:DropDownList&gt;
       &lt;/td&gt;
       &lt;td&gt;
           &lt;asp:TextBox ID="txb_date" runat="server" Width="146px"&gt;&lt;/asp:TextBox&gt;

           &lt;asp:CalendarExtender ID="txb_date_CalendarExtender" runat="server" Enabled="True" TargetControlID="txb_date"&gt;
           &lt;/asp:CalendarExtender&gt;

       &lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td style="width: 157px"&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
       &lt;td style="width: 157px"&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
       &lt;td&gt;&nbsp;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;

   &lt;br /&gt;
   &lt;br /&gt;
   &lt;asp:SqlDataSource ID="Ds_address" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TicketsConnectionString %&gt;" SelectCommand="SELECT * FROM [Streets]"&gt;&lt;/asp:SqlDataSource&gt;
   &lt;asp:SqlDataSource ID="DS_Employee" runat="server" ConnectionString="&lt;%$ ConnectionStrings:TicketsConnectionString %&gt;" SelectCommand="SELECT * FROM [Employee]"&gt;&lt;/asp:SqlDataSource&gt;
   &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
   &lt;/asp:ScriptManager&gt;

&lt;/asp:Content&gt;

在人們推薦的其他主題中添加此

&lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt; &lt;/asp:ScriptManager&gt;

但我在我的頁面上有它。任何想法如何解決?

母版頁程式碼

&lt;%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta name="keywords" content="" /&gt;
&lt;meta name="description" content="" /&gt;
&lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Tickets&lt;/title&gt;
&lt;link href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Archivo+Narrow:400,700" rel="stylesheet" type="text/css"&gt;
&lt;link href="style.css" rel="stylesheet" type="text/css" media="screen" /&gt;
   &lt;style type="text/css"&gt;
       .Buttons
       {
           font-family: Tahoma;
           font-size: large;
           background-color: #999999;
           border-bottom-color: #FF0000;
           border-style: none none outset none;
       }
       .Logins
       {
           font-family: tahoma;
           color: #FF0000;
       }
       .ButtonsInSite
       {
           font-family: tahoma;
           background-color: #C0C0C0;
           border-color: #FFFFFF #FFFFFF #FF0000 #FFFFFF;
           border-bottom-style: double;
           border-radius: 7px;
           -moz-border-radius: 7px;
           -webkit-border-radius: 7px;
           box-shadow: 0px 2px 9px #800000;
           font-weight: bold;
       }
   &lt;/style&gt;
   &lt;/head&gt;
&lt;body&gt;
   &lt;form id="form1" runat="server"&gt;
&lt;div id="header-wrapper"&gt;
   &lt;div id="header"&gt;
       &lt;div id="logo"&gt;
           &lt;h1&gt;Tickets&lt;/h1&gt;
           &lt;div style="text-align: right"&gt;

               &lt;asp:LoginName ID="LoginName2" runat="server" CssClass="Logins" /&gt;
               &nbsp;|
               &lt;asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="Logins" /&gt;
           &lt;/div&gt;
       &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;
&lt;div id="wrapper"&gt; 
   &lt;!-- end #header --&gt;
   &lt;div id="page"&gt;
       &lt;div id="page-bgtop"&gt;
           &lt;div id="page-bgbtm"&gt;
               &lt;div id="sidebar"&gt;
                   &lt;h2&gt;Navigation&lt;/h2&gt;
                   &lt;asp:Button ID="Button1" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite" /&gt;
                   &lt;br /&gt;
                   &lt;asp:Button ID="Button2" runat="server" Text="Button" Width="118px"  CssClass="ButtonsInSite"/&gt;
                   &lt;br /&gt;
                   &lt;asp:Button ID="Button3" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/&gt;
                   &lt;br /&gt;
                   &lt;asp:Button ID="Button4" runat="server" Text="Button" Width="118px" CssClass="ButtonsInSite"/&gt;
                   &lt;br /&gt;
                   &lt;asp:Button ID="Button5" runat="server" Text="Admin" Width="118px" CssClass="ButtonsInSite" PostBackUrl="~/Admin/AdmStart.aspx"/&gt;
                   &lt;br /&gt;


               &lt;/div&gt;
               &lt;!-- end #sidebar --&gt;
               &lt;div id="content"&gt;
                   &lt;asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"&gt;
                   &lt;/asp:ContentPlaceHolder&gt;
               &lt;/div&gt;
               &lt;!-- end #content --&gt;

               &lt;div style="clear: both;"&gt;&nbsp;&lt;/div&gt;
           &lt;/div&gt;
       &lt;/div&gt;
   &lt;/div&gt;
   &lt;!-- end #page --&gt; 
&lt;/div&gt;
&lt;div id="footer"&gt;
   &lt;p&gt; © 2013&lt;/p&gt;
&lt;/div&gt;
&lt;!-- end #footer --&gt;
   &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

可能這會對你有所幫助。母版頁 Html

&lt;asp:ContentPlaceHolder ID="head" runat="server"&gt;
&lt;/asp:ContentPlaceHolder&gt;

   &lt;asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"&gt;
&lt;/asp:ContentPlaceHolder&gt;

子頁面 Html

&lt;asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"&gt;Add Scripts here&lt;/asp:Content&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"&gt;
Add Page Content Here&lt;/asp:Content&gt;

在母版頁中添加

&lt;head runat="server"&gt;

引用自:https://stackoverflow.com/questions/18371538