I am new to ASP.NET MVC4 With Entity Framework. I just want to pass the value from View to Controller, I am unable to get it. Please help me to get it. Thanks in advance.
This is my View code:
<form id="changepassword" method="post" action="@Url.Action("Change", "ChangePassword")">
<input type="password" value="currentpswd" class="form-control pword" placeholder="Current Password" />
<input type="password" value="newpswd" class="form-control pword" placeholder="New Password" />
<input type="password" value="cnfrmpswd" class="form-control pword" placeholder="Confirm Password" />
<button class="btn btn-success btn-block" value="change">Submit</button>
</form>
This is my Controller code:
[HttpPost]
public ActionResult Change(FormCollection forms)
{
if (ModelState.IsValid)
{
string currentpswd=Convert.ToString(forms["currentpswd"]);
string newpass= (string)forms["newpswd"];
string confirmpass=forms["cnfrmpswd"];
Tbl_Users user = new Tbl_Users();
if (newpass == confirmpass)
{
user.UserPassword = newpass;
db.SaveChanges();
}
else
{
}
}
return RedirectToAction("Index", "ChangePassword");
}