コード例 #1
0
        internal static string HiddenInputTemplate(HtmlHelper html) {
            string result;

            if (html.ViewContext.ViewData.ModelMetadata.HideSurroundingChrome) {
                result = String.Empty;
            }
            else {
                result = DefaultDisplayTemplates.StringTemplate(html);
            }

            object model = html.ViewContext.ViewData.Model;

            Binary modelAsBinary = model as Binary;
            if (modelAsBinary != null) {
                model = Convert.ToBase64String(modelAsBinary.ToArray());
            }
            else {
                byte[] modelAsByteArray = model as byte[];
                if (modelAsByteArray != null) {
                    model = Convert.ToBase64String(modelAsByteArray);
                }
            }

            result += html.Hidden(String.Empty, model).ToHtmlString();
            return result;
        }