MVC3 で「ChangePassword」ビューを作成するのを手伝ってもらえますか?
ここで私がやろうとしたこと:
ProfileTeacherController.cs
public ViewResult ChangePassword(int id)
{
var user = User.Identity.Name;
int inter = int.Parse(user);
var teachers = from t in db.Teachers
where t.AffiliationNumber == inter
select t;
Teacher teacher = new Teacher();
foreach (var teach in teachers)
{
teacher = teach;
}
return View(teacher);
}
[HttpPost]
public ActionResult ChangePassword(Teacher teacher)
{
if (ModelState.IsValid)
{
// How can I compare the two fields password in my view ?
db.Entry(teacher).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Edit", "ProfileTeacher", new { id = teacher.TennisClubID });
}
return View(teacher);
}
ここで ChangePassword (表示)
@model TennisOnline.Models.Teacher
@{
ViewBag.Title = "ChangePassword";
}
<h2>Changement du mot de passe</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend></legend>
<div class="editor-label">
@Html.Label("Enter the new password")
</div>
<div class="editor-field">
@Html.PasswordFor(model => model.Pin, new { value = Model.Pin })
</div>
<div class="editor-label">
@Html.Label("Confirm your password")
</div>
<div class="editor-field">
@Html.Password("ConfirmPassword")
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
では、2 つのパスワードが同じかどうかをコントローラーで確認するにはどうすればよいですか? 前もって感謝します