2013-10-28 53 views
0

的ASP.NET Web表單項目有一些默認的頁面(「關於」和「聯繫」是特定的),有該類型的內容:爲什麼添加的網頁表單與默認表單不同?

<%@ 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中;我不積極其他版本是相同的。

回答

5

您沒有使用母版頁創建Web窗體。當您右鍵單擊該項目時,單擊添加項目,然後在Web下它將具有Web窗體,然後是其他類。使用主頁面使用Web窗體應該給你一個你想要的。聽起來像你使用的是空白的Web表單,並沒有site.master鏈接到它的Web窗體使用主頁鏈接爲您的site.master。

相關問題