public virtual object GetValue() { if (!RowData.Keys.Contains(FieldName) || RowData[FieldName] == null || RowData[FieldName].ToString().IsNullOrEmpty()) { RowData[FieldName] = DefaultValue.IsNullOrEmpty() ? string.Empty : DefaultValue; } object result = RowData[FieldName]; if (ColumnConverter != null) { result = ColumnConverter.Converter(FieldName, result, RowData); } else { if (!DataFormatString.IsNullOrEmpty() && !HtmlEncode) { if (!DataFormatFields.IsNullOrEmpty()) { var dataFields = DataFormatFields.Split(','); object[] param = new object[dataFields.Length]; for (int i = 0; i < dataFields.Length; i++) { param[i] = RowData[dataFields[i]]; } result = string.Format(CultureInfo.CurrentCulture, DataFormatString, param); } else { result = string.Format(CultureInfo.CurrentCulture, DataFormatString, new object[] { result }); } } } return result; }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); string treatCRasOneChar = "false"; if (TreatCarriageReturnsAsOneCharacter) { treatCRasOneChar = "true"; } /* We need to add three bits of JavaScript to the page: * (1) The include file that has the JavaScript function to count the characters/words * (2) JavaScript that will call the appropriate function in (1) when a key is pressed in the TextBoxControlId TextBox * (3) JavaScript to set the display for this control when the page is first loaded. */ // (1) Register the EvolutionNet.Util.Web client-side functions using WebResource.axd (if needed) // see: http://aspnet.4guysfromrolla.com/articles/080906-1.aspx if (Page != null && !Page.ClientScript.IsClientScriptIncludeRegistered("skmcontrols")) { Page.ClientScript.RegisterClientScriptInclude("skmcontrols", Page.ClientScript.GetWebResourceUrl(GetType(), "EvolutionNet.Util.Web.skm.js")); } // (2) Call skm_CountTextBox onkeyup TextBox tb = GetTextBoxControl(); tb.Attributes["onkeyup"] += string.Format("skm_CountTextBox('{0}', '{1}', '{2}', {3}, {4}, {5}, '{6}', '{7}', '{8}', {9});", tb.ClientID, ClientID, DataFormatString.Replace("'", "\\'"), treatCRasOneChar, MaxCharacterLength, MaxWordLength, CssClass, CssClassForWarning, CssClassForMax, WarningPercentage); // (3) Call skm_CountTextBox on page load if (Page != null) { Page.ClientScript.RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), string.Format( "skm_CountTextBox('{0}', '{1}', '{2}', {3}, {4}, {5}, '{6}', '{7}', '{8}', {9});", tb.ClientID, ClientID, DataFormatString.Replace("'", "\\'"), treatCRasOneChar, MaxCharacterLength, MaxWordLength, CssClass, CssClassForWarning, CssClassForMax, WarningPercentage), true); } }
public override object Converter(object value) { if (!DataFormatString.IsNullOrEmpty()) { if (!DataFormatFields.IsNullOrEmpty()) { var dataFields = DataFormatFields.Split(','); object[] param = new object[dataFields.Length]; for (int i = 0; i < dataFields.Length; i++) { param[i] = RowData[dataFields[i]]; } value = string.Format(CultureInfo.CurrentCulture, DataFormatString, param); } else { value = string.Format(CultureInfo.CurrentCulture, DataFormatString, new object[] { value }); } } return(value); }