コード例 #1
0
        protected string RenderBasicScripts(CultureInfo format)
        {
            if (baseScriptsRendered)
            {
                return(string.Empty);
            }
            baseScriptsRendered = true;

            StringBuilder sb = new StringBuilder();

            sb.Append(BasicHtmlHelper.RenderDisplayInfo(htmlHelper, this.GetType(), prefix));
            bool isClientBlock = htmlHelper.ViewData["ClientBindings"] != null ||
                                 htmlHelper.ViewContext.HttpContext.Items.Contains("ClientTemplateOn");

            sb.Append(string.Format(startScriptFormat,
                                    BasicHtmlHelper.IdFromName(BasicHtmlHelper.AddField(this.totalPrefix, "$")),
                                    BasicHtmlHelper.JavaScriptDate(min, isClientBlock),
                                    BasicHtmlHelper.JavaScriptDate(max, isClientBlock),
                                    clientOnChanged != null ? clientOnChanged + " return" : " return;",
                                    BasicHtmlHelper.JavaScriptDate(curr),
                                    clientMinScript,
                                    clientMaxScript,
                                    yearCombo ? "true" : "false",
                                    dateHidden ? "true" : "false",
                                    clientRefreshRegistrations,
                                    this.dateInCalendar ? "true" : "false",
                                    BasicHtmlHelper.GetAttributesString(attributeExtensions),
                                    totalPrefix
                                    ));
            sb.Append(BasicHtmlHelper.TrueValue(htmlHelper, this.totalPrefix, curr));
            FormatAttribute[] formatAttributes = pAccesor[typeof(FormatAttribute)] as FormatAttribute[];
            if (formatAttributes != null && formatAttributes.Length > 0)
            {
                sb.Append(BasicHtmlHelper.FormattedValueString(htmlHelper, this.totalPrefix, formatAttributes[0].HtmlEncode ? htmlHelper.Encode(formatAttributes[0].GetDisplay(curr)) : formatAttributes[0].GetDisplay(curr)));
            }
            else
            {
                DisplayFormatAttribute[] dFormatAttributes = pAccesor[typeof(DisplayFormatAttribute)] as DisplayFormatAttribute[];
                if (dFormatAttributes != null && dFormatAttributes.Length > 0)
                {
                    sb.Append(BasicHtmlHelper.FormattedValueString(htmlHelper, this.totalPrefix, dFormatAttributes[0].HtmlEncode ? htmlHelper.Encode(
                                                                       new FormatAttribute(dFormatAttributes[0]).GetDisplay(curr)) : new FormatAttribute(dFormatAttributes[0]).GetDisplay(curr)));
                }
            }
            if (format != null)
            {
                WriteMonthes(sb, format);
            }
            return(sb.ToString());
        }