我的表单中有一个文本框。我有一个类TicketUser,我有访问器设置为在我的标签中返回一个值。我试图从标签内的文本框中获取值。我试图让firstName从我的表单中返回txtfirstName.Text的值。请有人请指导我正确的方向。我是asp.net的新手
public class TicketUser
{
public string firstName;
public string lastName;
public string username;
TicketForm form = new TicketForm();
//property accessors
public string CreateAccountMessage
{
get
{
return "Congratulations" + firstName + "Your account has been created. Your username is" + username;
}
set
{
CreateAccountMessage = value;
}}
//CreateAccount method
public string CreateAccount()
{
return CreateAccountMessage;
}}}
答案 0 :(得分:1)
改变这个:
public string firstName = "";
public string lastName = "";
public string username = "";
答案 1 :(得分:1)
我希望我能帮到你,因为你需要了解一些关于你要做什么以及结果是什么的细节。 在表单的代码隐藏文件中设置和设置TicketUser并设置
t = new TicketUser();
t.firstName=txtfirstName.Text;
t.lastName=txtlastName.Text;
t.userName=txtUsername.Text;