How to add error state to the partially rendered view
Hi...
I have a home screen in which I have header footer and some content. In the content area, I am rendering login control as a partial view. Now I am trying to provied validations to login control. Here is code of my surface controller for login
[HttpPost]
[ActionName("Login")]
public ActionResult Login(LoginCommand command)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(command.Username, command.Password))
{
FormsAuthentication.SetAuthCookie(command.Username, command.RememberMe);
if (command.RememberMe)
{
Response.Cookies["UserName"].Value = command.Username;
Response.Cookies["Password"].Value = command.Password;
}
return PartialView("Details", command);
}
else
{
ModelState.AddModelError("Login", "Invalid username or password");
return PartialView("Login", new LoginCommand());
}
}
return PartialView("Login", new LoginCommand());
}
But when I return partial view with error, it is being rendered in a new page, not in the same location( in the home page). How should we render the view with error state in the home screen also by preserving model state?
How to add error state to the partially rendered view
Hi...
I have a home screen in which I have header footer and some content. In the content area, I am rendering login control as a partial view. Now I am trying to provied validations to login control. Here is code of my surface controller for login
But when I return partial view with error, it is being rendered in a new page, not in the same location( in the home page). How should we render the view with error state in the home screen also by preserving model state?
is working on a reply...