簡體   English   中英

僅允許內容控件(C#webcontrols)

[英]Only Content Controls are Allowed (C# webcontrols)

所以,我不確定發生了什么。 我的老板對我使用MVC和Razor不滿意,所以我被迫使用這種令人討厭的webcontrol / codebehind風格進行編碼。 = /

錯誤是:

Only Content controls are allowed directly in a content page that contains Content controls.

這是主頁:

<%@ 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>

這是拋出錯誤的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>

愚蠢的Default.aspx.cs代碼隱藏......

使用系統; 使用System.Web; 使用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!";
                    }
            }
    }
}

您的所有內容,包括靜態HTML的必須是內部Content在內容頁面的標簽。 你外面有一個<h2>

<h2>Application Form</h2>
<asp:Content id="content" ContentPlaceHolderID="contentPlaceHolder" runat="server">

應該:

<asp:Content id="content" ContentPlaceHolderID="contentPlaceHolder" runat="server">
    <h2>Application Form</h2>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM