hi,
view:
- @using (Html.BeginForm())
- {
- @Html.ValidationSummary(true, "Login Failed, check details");
-
- <div>
-
- <br />
-
- <fieldset>
- <legend>Login Form</legend>
- <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>
- }
controller:
- public ActionResult Index()
- {
- return View();
- }
-
- [ChildActionOnly]
- public ActionResult Login()
- {
- return PartialView("_Login");
- }
-
- [HttpPost]
-
-
- 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(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.