【问题标题】:Why is an added web form different from the default forms?为什么添加的 Web 表单与默认表单不同?
【发布时间】:2013-10-28 18:49:17
【问题描述】:

一个 ASP.NET Webforms 项目有一些默认页面(具体来说是“关于”和“联系”),它们具有这种类型的内容:

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Title %>.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p>
</asp:Content>

然而,当您选择添加 > Web 表单时,它会创建以下内容:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DuckbilledPlatypus.aspx.cs" Inherits="DuckbilledPlatypus" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

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

为什么会出现差异/不一致?注意:这是在 Visual Studio 2013 中;我不肯定其他版本是一样的。

【问题讨论】:

    标签: asp.net visual-studio webforms visual-studio-2013


    【解决方案1】:

    您没有使用母版页创建 Web 表单。当您右键单击项目时,单击添加项目,然后在 Web 下它将具有 Web 窗体,然后还有其他类。使用母版页使用 Web 表单应该会给你你想要的。听起来您使用的是空白 Web 表单,并且没有 site.master 链接到它,其中使用母版页的 Web 表单为您链接了 site.master。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      • 2010-10-22
      • 2020-12-23
      • 2011-01-19
      相关资源
      最近更新 更多