MvcHtmlHelpers.cs 549 B

1234567891011121314151617
  1. using System;
  2. using System.Linq.Expressions;
  3. using System.Web.Mvc;
  4. namespace CD67.ModeleMVC.MVC
  5. {
  6. public static class MvcHtmlHelpers
  7. {
  8. public static MvcHtmlString DescriptionFor<TModel, TValue>(this HtmlHelper<TModel> self, Expression<Func<TModel, TValue>> expression)
  9. {
  10. var metadata = ModelMetadata.FromLambdaExpression(expression, self.ViewData);
  11. var description = metadata.Description;
  12. return MvcHtmlString.Create(string.Format(@"<span>{0}</span>", description));
  13. }
  14. }
  15. }