Reputation: 131
For now I'm watching youtube video, and in the very fast video about Hello World I'm already having problems, because after creating a Web Form (I'm using Visual Studio 2017), I added a textbox to the aspx file that now contains:
<%@ 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>
But after adding this, in the youtube video in the cs file it automatically generates a .Page_Load method, but in my IDE, I don't why, it isn't generated automatically, so I manually added the method and code, but after executing it, the textbox is empty. Can anyone help me to understand first of all why in my IDE it doesn't create the Page_Load() method automatically, and then why after adding it manually it still not working?
This is my .designer.cs file:
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!";
}
}
}
Upvotes: 1
Views: 575
Reputation: 131
I solved it, I was editing the .aspx.designer.cs instead of the .aspx.cs file.
Upvotes: 1