Created
July 25, 2012 11:47
-
-
Save yojimbo87/3175713 to your computer and use it in GitHub Desktop.
POST validation dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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