1
現在我正在觀看YouTube視頻,並且在關於Hello World的非常快速的視頻中,我已經遇到了問題,因爲在創建Web窗體之後(我正在使用Visual Studio 2017 ),我添加了一個文本框,現在包含aspx文件:ASP.NET Beginner(Hello World)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.designer.cs" Inherits="HelloWorlds.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="item1" runat="server"> </asp:TextBox>
</div>
</form>
</body>
</html>
但添加在此之後,在CS中的YouTube視頻文件,它會自動生成一個.Page_Load方法,但在我的IDE,我不爲什麼,它不是自動生成的,所以我手動添加了方法和代碼,但執行後,文本框是空的。任何人都可以幫助我理解首先爲什麼在我的IDE中它不會自動創建Page_Load()方法,然後爲什麼在手動添加之後仍然無法工作?
這是我的了.Designer.cs文件:
namespace HelloWorlds {
public partial class WebForm1 {
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// item1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox item1;
void Page_Load()
{
item1.Text = "Test001!";
}
}
}
你不從_System.Web.UI.Page_ – Steve
派生你的頁面類我向WebForm1類添加了「:System.Web.UI.Page」,但它仍然不起作用 –
如果你是新手ASP.NET開發,爲什麼要開始使用Web Forms,一個垂死的框架? – mason