I have three buttons in one view and if i submit second button it's not submitting.
please help me.
View :
@model sb_admin_2.Web.Models.Account.LoginAuthontication
@using (Html.BeginForm("HomePage", "UserLoginhome", FormMethod.Post, null))
{
@Html.AntiForgeryToken()
<div class="row ml0 mr0 login-bg">
<div class="container">
<div class="col-md-4 login1">
<h3 class="h3 text-center">Corporate Login</h3>
<form class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div>
<span class="text-danger"> @TempData["CorparateError"] </span>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CorpLogin.CorpEmailId, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.CorpLogin.CorpEmailId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CorpLogin.CorpEmailId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CorpLogin.CorpPassword, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.CorpLogin.CorpPassword, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CorpLogin.CorpPassword, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<div class="checkbox">
@*<label><input type="checkbox"> Remember me</label>*@
@Html.CheckBoxFor(m => m.CorpLogin.CorpRemeberMe)
@Html.DisplayNameFor(m => m.CorpLogin.CorpRemeberMe)
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-primary wide" name="Command" value="CorparateLogin">Login</button>
</div>
</div>
</form>
</div>
<div class="col-md-4 login1">
<h3 class="h3 text-center">Individual Login</h3>
<form class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div>
<span class="text-danger"> @TempData["IndividualError"]</span>
</div>
<div class="form-group">
@Html.LabelFor(model => model.IndLogin.IndEmailId, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.IndLogin.IndEmailId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.IndLogin.IndEmailId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.IndLogin.IndPassword, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.IndLogin.IndPassword, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.IndLogin.IndPassword, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<div class="checkbox">
@Html.CheckBoxFor(m => m.IndLogin.IndRemeberMe)
@Html.DisplayNameFor(m => m.IndLogin.IndRemeberMe)
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-primary wide" name="Command" value="IndividualLogin">Login</button>
</div>
</div>
</form>
</div>
<div class="col-md-4 login1">
<h3 class="h3 text-center">Candidate Login</h3>
<form class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div>
<span class="text-danger"> @TempData["CandidateError"] </span>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CandLogin.CandUserId, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.CandLogin.CandUserId, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CandLogin.CandUserId, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CandLogin.CandPassword, new { @class = "control-label col-md-3", })
<div class="col-md-9">
@Html.EditorFor(model => model.CandLogin.CandPassword, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.CandLogin.CandPassword, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<div class="checkbox">
@Html.CheckBoxFor(m => m.CandLogin.CandRemeberMe)
@Html.DisplayNameFor(m => m.CandLogin.CandRemeberMe)
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn btn-primary wide" name="Command" value="CandidateLogin">Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
<!--
}
public ActionResult HomePage()
{
LoginAuthontication model = new LoginAuthontication();
ViewBag.message = Session["Message"];
return View(model);
}
[HttpPost]
public ActionResult HomePage(LoginAuthontication model, string Command)
{
if (Command == "CorparateLogin")
{
var corpLogin = db.ALOrganizationUsers.FirstOrDefault(m => m.UserEmailID == model.CorpLogin.CorpEmailId && m.UserPassword == model.CorpLogin.CorpPassword);
if (model.CorpLogin.CorpRemeberMe == true)
{
HttpCookie cookie = new HttpCookie("YourAppLogin");
cookie.Values.Add("username", corpLogin.UserEmailID);
cookie.Expires = DateTime.Now.AddDays(15);
Response.Cookies.Add(cookie);
}
if (corpLogin != null)
{
return RedirectToAction("Index", "UserLoginhome");
}
else
{
TempData["CorparateError"] = "Login data is incorrect";
}
}
else if (Command == "IndividualLogin")
{
var indLogin = db.ALLoginIndividuals.FirstOrDefault(m => m.UserEmailID == model.IndLogin.IndEmailId && m.UserPassword == model.IndLogin.IndPassword);
if (model.IndLogin.IndRemeberMe == true)
{
HttpCookie cookie = new HttpCookie("YourAppLogin");
cookie.Values.Add("username", indLogin.UserEmailID);
cookie.Expires = DateTime.Now.AddDays(15);
Response.Cookies.Add(cookie);
}
if (indLogin != null)
{
return RedirectToAction("Index", "UserLoginhome");
}
else
{
TempData["IndividualError"] = "Login data is incorrect";
}
}
else
{
var candLogin = db.ALUserDetails.FirstOrDefault(m => m.UserID == model.CandLogin.CandUserId && m.Pword == model.CandLogin.CandPassword);
if (candLogin != null)
{
return RedirectToAction("ALLBulkTestUserDetails", "UserLoginhome");
}
else
{
TempData["CandidateError"] = "Login data is incorrect";
}
}
return View();
}
public class LoginAuthontication
{
public CorprateLogin CorpLogin { get; set; }
public IndividualLogin IndLogin { get; set; }
public CandidateLogin CandLogin { get; set; }
}
public class CorprateLogin
{
[Required(ErrorMessage = "*Please Enter Email ID")]
[Display(Name = "Email ID")]
public string CorpEmailId { get; set; }
[Required(ErrorMessage = "*Please Enter Password")]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string CorpPassword { get; set; }
[Display(Name = "Remember me?")]
public bool CorpRemeberMe { get; set; }
}
public class IndividualLogin
{
[Required(ErrorMessage = "*Please Enter Email ID")]
[Display(Name = "Email ID")]
public string IndEmailId { get; set; }
[Required(ErrorMessage = "*Please Enter Password")]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string IndPassword { get; set; }
[Display(Name = "Remember me?")]
public bool IndRemeberMe { get; set; }
}
public class CandidateLogin
{
[Required(ErrorMessage = "*Please Enter Email ID")]
[Display(Name = "Email ID")]
public decimal CandUserId { get; set; }
[Required(ErrorMessage = "*Please Enter Password")]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string CandPassword { get; set; }
[Display(Name = "Remember me?")]
public bool CandRemeberMe { get; set; }
}