1
我的ASP.NET MVC應用程序有一些問題。如何修改先前在不同ActionResult
中創建的現有對象?修改ASP.NET中的現有對象
我在這個動作中創建對象:
public ActionResult getLogin(AccountViewModel accountViewModel)
{
Account account2 = de.Accounts.FirstOrDefault(a => a.Username == accountViewModel.Account.Username);
PasswordReminder.PasswordReminder reminder = new PasswordReminder.PasswordReminder();
reminder.showQuestion(account2.Username);
return View("Question", reminder);
}
而且我想通過這個ActionResult的
@model PasswordReminder.PasswordReminder
@{
Layout = null;
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Question</title>
</head>
<body>
<div>
@Model.questionReminder
@using (Html.BeginForm("Answer", "Account", FormMethod.Post))
{
@Html.TextBoxFor(a => a.reminderAnswer)
<input type="submit" value="Send" />
}
</div>
</body>
</html>
所以,在我看來,「答案」的屬性添加到現有的提醒對象屬性「 reminderAnswer「我輸入的值,但questionReminder爲null,所以這必須是一個新的對象..感謝所有幫助