Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. //First Html.BeginForm()
  2. @using (Html.BeginForm("AddFirst", "Student", FormMethod.Post, new { id = "form1", role = "form" }))
  3. {
  4. <tr>
  5. <td>
  6. @Html.LabelFor(model => model.MobileNo)
  7. @Html.EditorFor(model => model.MobileNo, new { htmlAttributes = new { id = "TextMobile", @class = "form-control", @maxlength = "10", @placeholder = "Mobile No" } })
  8. @Html.ValidationMessageFor(model => model.MobileNo, "", new { @class = "text-danger" })
  9. </td>
  10. <td>
  11. <input type="submit" name="submit" value="First Button" class="btn btn-default" />
  12. </td>
  13. </tr>
  14. }
  15.  
  16. //Second Html.BeginForm()
  17. @using (Html.BeginForm("AddSecond", "Student", FormMethod.Post, new { id = "form2", role = "form" }))
  18. {
  19. <tr>
  20. <td>
  21. @Html.LabelFor(model => model.MobileNo)
  22. @Html.EditorFor(model => model.MobileNo, new { htmlAttributes = new { id = "TextMobile2", @class = "form-control", @maxlength = "10", @placeholder = "Mobile No" } })
  23. @Html.ValidationMessageFor(model => model.MobileNo, "", new { @class = "text-danger" })
  24. </td>
  25. <td>
  26. <input type="submit" name="submit" value="Second Button" class="btn btn-default" />
  27. </td>
  28. </tr>
  29. }
  30.  
  31. [HttpPost]
  32. public ActionResult AddFirst(string submit, User u)
  33. {
  34. agree = new Agree(u);
  35. if (ModelState.IsValid)
  36. {
  37. //Some logic
  38. return View("ThisView", agree);
  39. }
  40. else
  41. {
  42. return View("ThisView", agree);
  43. }
  44.  
  45. }
  46.  
  47.  
  48. [HttpPost]
  49. public ActionResult AddSecond(string submit, User u)
  50. {
  51. agree = new Agree(u);
  52. if (ModelState.IsValid)
  53. {
  54. //Some logic
  55. return View("ThisView", agree);
  56. }
  57. else
  58. {
  59. return View("ThisView", agree);
  60. }
  61.  
  62. }
  63.  
  64. [DisplayName("Mobile Number")]
  65. [Required(ErrorMessage = "* Please Enter Mobile Number")]
  66. public string MobileNo { get; set; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement