/// /// Extension methods for the class. /// public static class ControlExtensions { /// /// Evaluates a data-binding expression at run time and returns a HTML-encoded result. /// /// The control this extension method is attached to. /// /// The navigation path from the container object to the public property value to be placed in the bound control property. /// This must be a string of property or field names separated by periods, such as Tables[0].DefaultView.[0].Price /// /// /// Because this method performs late-bound evaluation, using reflection at run time, it can cause performance /// to noticeably slow compared to standard ASP.NET data-binding syntax. Use this method judiciously. /// /// A HTML-encoded instance that results from the evaluation of the data-binding expression. public static string EncodeEval( this Control control, string expression ) { return HttpUtility.HtmlEncode( DataBinder.Eval( control.Page.GetDataItem(), expression ).ToString() ); } /// /// Evaluates a data-binding expression at run time and returns a HTML-encoded result. /// /// The control this extension method is attached to. /// /// The navigation path from the container object to the public property value to be placed in the bound control property. /// This must be a string of property or field names separated by periods, such as Tables[0].DefaultView.[0].Price /// /// /// A .NET Framework format string (like those used by ) that converts the instance /// returned by the data-binding expression to a object. /// /// /// Because this method performs late-bound evaluation, using reflection at run time, it can cause performance /// to noticeably slow compared to standard ASP.NET data-binding syntax. Use this method judiciously, particularly when string formatting is not required. /// /// A HTML-encoded instance that results from the evaluation of the data-binding expression. public static string EncodeEval( this Control control, string expression, string format ) { return HttpUtility.HtmlEncode( DataBinder.Eval( control.Page.GetDataItem(), expression, format ).ToString() ); } }