Created
April 21, 2016 17:33
-
-
Save rionmonster/2a62521a07335bb56d20dc897ef0ba94 to your computer and use it in GitHub Desktop.
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
public class HomeController : Controller | |
{ | |
[HttpGet] | |
public ActionResult Index() | |
{ | |
return View(); | |
} | |
[HttpPost] | |
public ActionResult Index(string posted) | |
{ | |
return Content(posted + " was posted."); | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Post Testing</title> | |
</head> | |
<body> | |
<h2>Normal Form</h2> | |
@using (Html.BeginForm("Index", "Home")) | |
{ | |
<input type="hidden" name="posted" id="posted" value="5" /> | |
<input type="submit" id="sBtn" value="Submit" /> | |
} | |
<h2>AJAX Form</h2> | |
@using (Ajax.BeginForm("Index", "Home", new AjaxOptions() { HttpMethod = "Post", UpdateTargetId = "DivName" })) | |
{ | |
<input type="hidden" name="posted" id="posted" value="5" /> | |
<input type='submit'> | |
} | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment