Skip to content

Instantly share code, notes, and snippets.

@yojimbo87
Created July 25, 2012 11:47
Show Gist options
  • Save yojimbo87/3175713 to your computer and use it in GitHub Desktop.
Save yojimbo87/3175713 to your computer and use it in GitHub Desktop.
POST validation dump
Statistics partial<br />
<br />
@using(Html.BeginForm("Index", "Statistics", FormMethod.Post, new { id = "form-post" }))
{
@Html.AntiForgeryToken()
@Html.TextBoxFor(m => m.Name)
@Html.ValidationMessageFor(m => m.Name)
<div id="button-wrapper-1">
<input type="submit" id="send-post" value="Post" />
</div>
}
[Authorize]
[HttpPost]
public ActionResult Index(Foo viewModel)
{
if (!ModelState.IsValid)
{
return PartialView(viewModel);
}
return RedirectToAction("Index");
}
public class Foo
{
[Required(ErrorMessage = "Name is requireddddd!")]
public string Name { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment