Guest User

Untitled

a guest
Jun 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. public class TestObject
  2. {
  3. public string Name { get; set; }
  4. public int Age { get; set; }
  5. }
  6.  
  7. <form action="/Create" method="post">
  8. <p>
  9. <%=Html.TextBox("Name") %>
  10. </p>
  11. <p>
  12. <%=Html.TextBox("Age")%>
  13. </p>
  14. </form>
  15.  
  16. [AcceptVerbs(HttpVerbs.Get)]
  17. public ActionResult Create()
  18. {
  19. return View(new TestObject { Name = "DefaultName", Age = 10 } );
  20. }
  21.  
  22. [AcceptVerbs(HttpVerbs.Post)]
  23. public ActionResult Create(TestObject o)
  24. {
  25. o.Name = "ChangedNameToSomethingElse";
  26. o.Age = 15;
  27. return View(o);
  28. }
Add Comment
Please, Sign In to add comment