Possible bug in ASP.NET MVC with form values being replaced

后端 未结 12 711
抹茶落季
抹茶落季 2020-11-29 00:41

I appear to be having a problem with ASP.NET MVC in that, if I have more than one form on a page which uses the same name in each one, but as different types (radio/hidden/e

12条回答
  •  难免孤独
    2020-11-29 00:47

    There is workaround:

        public static class HtmlExtensions
        {
            private static readonly String hiddenFomat = @"";
            public static MvcHtmlString HiddenEx(this HtmlHelper htmlHelper, string name, T[] values)
            {
                var builder = new StringBuilder(values.Length * 100);
                for (Int32 i = 0; i < values.Length; 
                    builder.AppendFormat(hiddenFomat,
                                            htmlHelper.Id(name), 
                                            values[i++].ToString(), 
                                            htmlHelper.Name(name)));
                return MvcHtmlString.Create(builder.ToString());
            }
        }
    

提交回复
热议问题