내가 다음과 같습니다 생성자와 "사람"클래스를 클릭추가 객체는
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Programming_handin_2___Arrays
{
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
public string Password { get; set; }
public Person(string name, int age, string password)
{
this.Name = name;
this.Age = age;
this.Password = password;
}
public override string ToString()
{
return Name + ", " + Age + ", " + Password;
}
}
}
또한 위의 변수를 추가하는 몇 가지 텍스트 상자와 함께 영문 페이지가 있습니다.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Name:<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
Age:<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
Password:<br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Add person" />
<br />
<br />
</div>
</form>
</body>
</html>
목표는 누군가가 양식을 채우고 버튼을 클릭 할 때마다 새로운 "사람"을 만드는 것입니다. "사람"이 페이지에 표시되어야합니다. 이것을 달성하는 가장 좋은 방법은 무엇입니까?
마지막 부분이 페이지에 표시되고 있습니까? – lxxtacoxxl
요청 수명을 설명하는 방법, 데이터가 여러 요청에 걸쳐 ASP.Net에서 유지되는 방법, 양식 작업 및 배열에 요소를 추가하는 것 (그 자체로 중요하지 않음)은 너무 까다로워 단일 질문에 맞지 않습니다. 지금 직면하고있는 문제의 범위를 좁히고 해당 질문을 대신 물어볼 수도 있지만 비슷한 질문을 먼저 찾아야합니다 (지금 당장은 힌트를주기 위해 중복으로 닫을 수 없습니다). –
@AlexeiLevenkov OP는 각 개인 객체에 대해 페이지에 포함 된 요소를 표시하는 방법을 알고 싶어한다는 추측을 통해 가정합니다. – lxxtacoxxl