vb.net 此页面缺少正在添加的 CSS 样式表链接所需的 HtmlHead 控件。请加

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13716772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 11:26:52  来源:igfitidea点击:

This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add

asp.netvb.net

提问by Mahendra

This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.NotSupportedException: This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[NotSupportedException: This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.]
   AjaxControlToolkit.ScriptObjectBuilder.RegisterCssReferences(Control control) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs:273
   AjaxControlToolkit.ScriptControlBase.OnLoad(EventArgs e) in d:\E\AjaxTk-AjaxControlToolkit\Release\AjaxControlToolkit\ExtenderBase\ScriptControlBase.cs:260
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Control.LoadRecursive() +141
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

i am using masterpage which has head tag which contain javascript and css code in it. it work well in local server but when file hosted live it give error

我正在使用具有 head 标记的母版页,其中包含 javascript 和 css 代码。它在本地服务器上运行良好,但是当文件托管时它会出错

i have added runat ="server" still getting the same error

我添加了 runat ="server" 仍然遇到同样的错误

<%@ Master Language="VB" CodeFile="MasterPageReg.master.vb" Inherits="MasterPageReg" %>

<%@ Master Language="VB" CodeFile="MasterPageReg.master.vb" Inherits="MasterPageReg" %>

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

    <title>
        <asp:Literal ID="litTitle" runat="server"></asp:Literal>
    </title>

</head>
<body>
    <form id="form1" runat="server">
    <table width="780" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#ECE9D8">
        <tr>
            <td>
                <table width="780" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td width="200" bgcolor="#FFFA9C">
                            <a href="default.aspx">
                                <img src="imghome/logo.jpg" width="200" height="172" title="Daptary's" border="0" /></a>
                        </td>
                        <td valign="top" align="right">
                            <table border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td>
                                    </td>
                                    <td height="6">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="right">
                                        &nbsp;
                                    </td>
                                    <td height="28" align="right">
                                        <a href="Default2.aspx" class="MainLink" title="Home">Home</a> <span class="MainLink">
                                        </span>&nbsp;<span class="MainLink"> </span><a href="contactus.aspx" class="MainLink"
                                            title="Contact Us"></a><span class="MainLink"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="2">
                                    </td>
                                    <td bgcolor="#F8C300">
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;
                                    </td>
                                    <td>
                                        &nbsp;
                                    </td>
                                </tr>
                            </table>
                            <asp:ScriptManager ID="ScriptManager1" runat="server">
                            </asp:ScriptManager>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="2" bgcolor="#F8C300">
            </td>
        </tr>
        <tr>
            <td height="6">
            </td>
        </tr>
        <tr class="REDBold1">
            <td height="20" class="REDBold1 table123" style="background-image: url(imghome/title1.jpg);
                background-repeat: repeat">
                &nbsp; &nbsp;
                <asp:Label ID="lbltitle" runat="server" CssClass="REDBold1" Font-Bold="True" ForeColor="#B12907"
                    ToolTip="Page Title"></asp:Label>
            </td>
        </tr>
        <tr>
            <td>

    </form>
</body>
</html>

this is code of master page

这是母版页的代码

回答by techChallenger

Try this solution

试试这个解决方案

1. Add a script manager

1.添加脚本管理器

<asp:ScriptManagerID="ScriptManager1"runat="server">
</asp:ScriptManager>

2. Add a javascript function

2.添加javascript函数

// Write following function which calls automatically
<script language="javascript" type="text/javascript">
        function show()
        {
              document.write("<head id="Head1" runat='server'></head>");
        }
</script>

and finally everything works fine. !!!

最后一切正常。!!!