I have a partial view called LogOn, where I basically copied the input to the control input. I use Html.RenderPartial to place the control in my Index.Html inside Ajax.BeginForm
<div id="login_ajaxtarget">
<% using (Ajax.BeginForm("Logon", "Account", new AjaxOptions { UpdateTargetId = "login_ajaxtarget", HttpMethod = "Post" })) { %>
<% Html.RenderPartial("LogOn"); %>
<% } %>
</div>
I am trying to pass verification messages and show them, but I cannot get it to work. I am passing the model to the view, but it does not seem to do the correct check.
My controller
public ActionResult LogOn(string userName, string password, bool rememberMe, string returnUrl)
{
if (!ValidateLogOn(userName, password))
{
return PartialView("LogOn", ModelState);
}
FormsAuth.SignIn(userName, rememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
My partial view
<%= Html.ValidationSummary("Login was unsuccessful. Please correct the errors and try again.") %>
<div>
<fieldset>
<legend>Account Information</legend>
<p>
<label for="username">Username:</label>
<%= Html.TextBox("username") %>
<%= Html.ValidationMessage("username") %>
</p>
<p>
<label for="password">Password:</label>
<%= Html.Password("password") %>
<%= Html.ValidationMessage("password") %>
</p>
<p>
<%= Html.CheckBox("rememberMe") %> <label class="inline" for="rememberMe">Remember me?</label>
</p>
<p>
<input type="submit" value="Log On" />
</p>
</fieldset>
</div>
(http://forums.asp.net/p/1398814/3023892.aspx#3023892), , . , , - LogOn , , . , Im ! .