hi,
view:
- @using (Html.BeginForm())
- {
- @Html.ValidationSummary(true, "Login Failed, check details");
- <div>
- <br />
- <fieldset>
- <legend>Login Formlegend>
- <div class="editor-label">@Html.LabelFor(u => u.UserName)div>
- <div class="editor-field">
- @Html.TextBoxFor(u => u.UserName)
- @Html.ValidationMessageFor(u => u.UserName)
- div>
- <div class="editor-label">@Html.LabelFor(u => u.Password)div>
- <div class="editor-field">
- @Html.PasswordFor(u => u.Password)
- @Html.ValidationMessageFor(u => u.Password)
- div>
- <br />
- <input type="submit" value="Log In" />
- <button class="btn btn-lg btn-success btn-block" type="submit">@Html.ActionLink("Login", "Login", "Home", new { /* ID TO BE PASSED*/ }, null)button>
- fieldset>
- div>
- }
- public ActionResult Index()
- {
- return View();
- }
- [ChildActionOnly]
- public ActionResult Login()
- {
- return PartialView("_Login");
- }
- [HttpPost]
- //[ValidateAntiForgeryToken]
- public ActionResult Login(Models.Account objUser)
- {
- if (ModelState.IsValid)
- {
- using (MyDatabaseEntities db = new MyDatabaseEntities())
- {
- var obj = db.Accounts.Where(a => a.UserName.Equals(objUser.UserName) && a.Password.Equals(objUser.Password)).FirstOrDefault();
- if (obj != null)
- {
- Session["UserName"] = obj.UserName.ToString();
- Session["IsAdmin"] = obj.IsAdmin.ToString();
- return RedirectToAction("Index", "Account");
- }
- }
- }
- // return View("Dashboard/Index");
- return View(objUser);
- }
i want login controller to be executed whn login is clicked. please suggest what id is to be passed from the view to execute public ActionResult Login(Models.Account objUser) controller.
Ramesh PalanivelPosted Apr 20, 2017, 2:53 AM
Saineshwar BageriPosted Apr 20, 2017, 2:39 AM
@Html.ValidationSummary(true, "Login Failed, check details");
public ActionResult Login()
{
return View();
}
[HttpPost]
public ActionResult Login(Model value)
{
return View();
}
Chandrakant VermaPosted Apr 20, 2017, 1:59 AM
Chandrakant VermaPosted Apr 20, 2017, 1:58 AM
Ramesh PalanivelPosted Apr 20, 2017, 1:56 AM
Saineshwar BageriPosted Apr 20, 2017, 1:48 AM