ASP.NET MVC 3 Custom HTML Helpers- Best Practices/Uses

后端 未结 3 1673
日久生厌
日久生厌 2020-12-07 07:58

New to MVC and have been running through the tutorials on the asp.net website.

They include an example of a custom html helper to truncate long text displayed in a

3条回答
  •  忘掉有多难
    2020-12-07 08:27

    public static HtmlString OwnControlName(this HtmlHelper helper, Expression> expression, string label_Name = "", string label_Title = "", Attr attr = null)
            {
                TemplateBuilder tb = null;
                string template = null;
              if (expression == null) throw new ArgumentException("expression");
     obj = helper.ViewData.Model;
                    tb.Build(obj, expression.Body as MemberExpression, typeof(T), new SimpleTemplate(new TextArea()), label_Name, label_Title, attr);
                    template = tb.Get();
     return new MvcHtmlString(template);
    }
    

提交回复
热议问题