FormExtensions.cs 630 B

123456789101112131415161718192021
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace System.Web.Mvc
  6. {
  7. public static class FormExtensions
  8. {
  9. public static System.Web.Mvc.Html.MvcForm BeginForm(this HtmlHelper htmlHelper,
  10. string formID = null, string formName = null)
  11. {
  12. string id = string.IsNullOrEmpty(formID) ? "form_" + Guid.NewGuid().ToString().Substring(0, 6) : formID;
  13. return System.Web.Mvc.Html.FormExtensions.BeginForm(htmlHelper, null, null, FormMethod.Post, new Dictionary<string, object>
  14. {
  15. { "id", id },
  16. { "name", string.IsNullOrEmpty(formName) ? id : formName }
  17. });
  18. }
  19. }
  20. }