asp.net 母版页验证 w3schools

标签 asp.net

但是,我正在验证网站的 default.aspx(使用母版页);我无法让它通过验证,因为之前出现的信息

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="EMSWebSite._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <link href="Styles/style.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

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

验证输出:3 个错误

Error Line 2, Column 1: character "<%" not allowed in prolog

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEve…

✉
Error Line 8, Column 80: document type does not allow element "asp:Content" here

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

✉

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
Error Line 10, Column 3: "DOCTYPE" declaration not allowed in instance

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o…

最佳答案

您应该验证生成的 HTML,而不是 ASPX 代码。

如果您想要一个快速且简单的解决方案,请使用浏览器显示代码并进行验证。

关于asp.net 母版页验证 w3schools,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8123114/

相关文章:

c# - 迭代数据表中的特定列

c# - 表中每一行的删除按钮 asp.Net C#

asp.net - Microsoft.VisualStudio.Web.PageInspector.Runtime.NativeMethods.CloseHandle

c# - 方法 "ToString"没有重载需要 1 个参数

javascript - 意外的标记,-asp 值显示为未定义

ASP.NET MVC 2.0 客户端验证 HOWTO

c# - WCF 服务不向 jQuery 返回值

javascript - 验证 asp :CheckBox control on client side using JavaScript and CustomValidator control

asp.net - 我可以创建.config文件并将其包含到web.config吗?

javascript - Web服务和网站在同一个项目中