[英]Only Content Controls are Allowed (C# webcontrols)
So, I'm not sure what's going on. 所以,我不确定发生了什么。 My boss wasn't pleased with me using MVC and Razor, so I'm being forced to code with this nasty webcontrol/codebehind style. 我的老板对我使用MVC和Razor不满意,所以我被迫使用这种令人讨厌的webcontrol / codebehind风格进行编码。 =/ = /
The error is: 错误是:
Only Content controls are allowed directly in a content page that contains Content controls.
Here is the masterpage: 这是主页:
<%@ Master Language="C#"%>
<!DOCTYPE html>
<html>
<head>
<title>Application Form</title>
</head>
<body>
<div id="container">
<asp:contentplaceholder id="contentPlaceHolder" runat="server" />
</div>
</body>
</html>
And here is the Default.aspx page that's throwing the error. 这是抛出错误的Default.aspx页面。
<%@ Page Language="C#" Inherits="dumb.Default" MasterPageFile="MasterPage.master" %>
<h2>Application Form</h2>
<asp:Content id="content" ContentPlaceHolderID="contentPlaceHolder" runat="server">
<p>Please complete this application.</p>
<form action="Default.aspx" method="post" runat="server">
<div>
<span class="spaced">Name:</span><asp:TextBox id="name" runat="server" />
</div>
</form>
<p>
<asp:Label id="finalmessage" runat="server" />
</p>
</asp:Content>
And the silly Default.aspx.cs codebehind... 愚蠢的Default.aspx.cs代码隐藏......
using System; 使用系统; using System.Web; 使用System.Web; using System.Web.UI; 使用System.Web.UI;
namespace dumb
{
public partial class Default : System.Web.UI.Page
{
protected void Page_Load (object sender, EventArgs e)
{
if (IsPostBack) {
finalmessage.Text = "Submission Processed Successfully!";
}
}
}
}
All of your content, including static HTML must be inside Content
tags in the content page. 您的所有内容,包括静态HTML的必须是内部Content
在内容页面的标签。 You have a <h2>
outside: 你外面有一个<h2>
:
<h2>Application Form</h2>
<asp:Content id="content" ContentPlaceHolderID="contentPlaceHolder" runat="server">
Should be: 应该:
<asp:Content id="content" ContentPlaceHolderID="contentPlaceHolder" runat="server">
<h2>Application Form</h2>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.