protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (base.RenderUplevel) { ValidationDataType enumValue = this.Type; if (enumValue != ValidationDataType.String) { string clientID = this.ClientID; HtmlTextWriter writer2 = base.EnableLegacyRendering ? writer : null; base.AddExpandoAttribute(writer2, clientID, "type", PropertyConverter.EnumToString(typeof(ValidationDataType), enumValue), false); NumberFormatInfo currentInfo = NumberFormatInfo.CurrentInfo; switch (enumValue) { case ValidationDataType.Double: { string numberDecimalSeparator = currentInfo.NumberDecimalSeparator; base.AddExpandoAttribute(writer2, clientID, "decimalchar", numberDecimalSeparator); return; } case ValidationDataType.Currency: { string currencyDecimalSeparator = currentInfo.CurrencyDecimalSeparator; base.AddExpandoAttribute(writer2, clientID, "decimalchar", currencyDecimalSeparator); string currencyGroupSeparator = currentInfo.CurrencyGroupSeparator; if (currencyGroupSeparator[0] == '\x00a0') { currencyGroupSeparator = " "; } base.AddExpandoAttribute(writer2, clientID, "groupchar", currencyGroupSeparator); base.AddExpandoAttribute(writer2, clientID, "digits", currentInfo.CurrencyDecimalDigits.ToString(NumberFormatInfo.InvariantInfo), false); int currencyGroupSize = GetCurrencyGroupSize(currentInfo); if (currencyGroupSize > 0) { base.AddExpandoAttribute(writer2, clientID, "groupsize", currencyGroupSize.ToString(NumberFormatInfo.InvariantInfo), false); return; } break; } case ValidationDataType.Date: { base.AddExpandoAttribute(writer2, clientID, "dateorder", GetDateElementOrder(), false); base.AddExpandoAttribute(writer2, clientID, "cutoffyear", CutoffYear.ToString(NumberFormatInfo.InvariantInfo), false); int year = DateTime.Today.Year; base.AddExpandoAttribute(writer2, clientID, "century", (year - (year % 100)).ToString(NumberFormatInfo.InvariantInfo), false); break; } } } } }
/// <include file='doc\basecomparevalidator.uex' path='docs/doc[@for="BaseCompareValidator.AddAttributesToRender"]/*' /> /// <internalonly/> /// <devdoc> /// AddAttributesToRender method /// </devdoc> protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (RenderUplevel) { ValidationDataType type = Type; if (type != ValidationDataType.String) { writer.AddAttribute("type", PropertyConverter.EnumToString(typeof(ValidationDataType), type)); NumberFormatInfo info = NumberFormatInfo.CurrentInfo; if (type == ValidationDataType.Double) { string decimalChar = NumberFormatInfo.CurrentInfo.NumberDecimalSeparator; writer.AddAttribute("decimalchar", decimalChar); } else if (type == ValidationDataType.Currency) { string decimalChar = info.CurrencyDecimalSeparator; writer.AddAttribute("decimalchar", decimalChar); string groupChar = info.CurrencyGroupSeparator; // Map non-break space onto regular space for parsing if (groupChar[0] == 160) { groupChar = " "; } writer.AddAttribute("groupchar", groupChar); int digits = info.CurrencyDecimalDigits; writer.AddAttribute("digits", digits.ToString(NumberFormatInfo.InvariantInfo)); } else if (type == ValidationDataType.Date) { writer.AddAttribute("dateorder", GetDateElementOrder()); writer.AddAttribute("cutoffyear", CutoffYear.ToString()); int currentYear = DateTime.Today.Year; int century = currentYear - (currentYear % 100); writer.AddAttribute("century", century.ToString()); } } } }
/// <internalonly/> /// <devdoc> /// AddAttributesToRender method /// </devdoc> protected override void AddAttributesToRender(HtmlTextWriter writer) { base.AddAttributesToRender(writer); if (RenderUplevel) { ValidationDataType type = Type; if (type != ValidationDataType.String) { string id = ClientID; HtmlTextWriter expandoAttributeWriter = (EnableLegacyRendering || IsUnobtrusive) ? writer : null; AddExpandoAttribute(expandoAttributeWriter, id, "type", PropertyConverter.EnumToString(typeof(ValidationDataType), type), false); NumberFormatInfo info = NumberFormatInfo.CurrentInfo; if (type == ValidationDataType.Double) { string decimalChar = info.NumberDecimalSeparator; AddExpandoAttribute(expandoAttributeWriter, id, "decimalchar", decimalChar); } else if (type == ValidationDataType.Currency) { string decimalChar = info.CurrencyDecimalSeparator; AddExpandoAttribute(expandoAttributeWriter, id, "decimalchar", decimalChar); string groupChar = info.CurrencyGroupSeparator; // Map non-break space onto regular space for parsing if (groupChar[0] == 160) { groupChar = " "; } AddExpandoAttribute(expandoAttributeWriter, id, "groupchar", groupChar); int digits = info.CurrencyDecimalDigits; AddExpandoAttribute(expandoAttributeWriter, id, "digits", digits.ToString(NumberFormatInfo.InvariantInfo), false); // VSWhidbey 83165 int groupSize = GetCurrencyGroupSize(info); if (groupSize > 0) { AddExpandoAttribute(expandoAttributeWriter, id, "groupsize", groupSize.ToString(NumberFormatInfo.InvariantInfo), false); } } else if (type == ValidationDataType.Date) { AddExpandoAttribute(expandoAttributeWriter, id, "dateorder", GetDateElementOrder(), false); AddExpandoAttribute(expandoAttributeWriter, id, "cutoffyear", CutoffYear.ToString(NumberFormatInfo.InvariantInfo), false); // VSWhidbey 504553: The changes of this int currentYear = DateTime.Today.Year; int century = currentYear - (currentYear % 100); AddExpandoAttribute(expandoAttributeWriter, id, "century", century.ToString(NumberFormatInfo.InvariantInfo), false); } } } }