• MVC视图中扩展helper(泛型绑定Model)


        @functions{
            public HelperResult EditBoxFor<TModel, TKey>(HtmlHelper<TModel> html, Expression<Func<TModel, TKey>> expression, bool disabled = false)
            {
                return EditBox(
                    html.LabelFor(expression, htmlAttributes: new { @class = "col-md-3 control-label" }),
                    disabled ? html.EditorFor(expression, new { htmlAttributes = new { @class = "form-control", disabled = "" } })
                        : html.EditorFor(expression, new { htmlAttributes = new { @class = "form-control" } }),
                    html.ValidationMessageFor(expression, "", new { @class = "text-danger" })
                    );
            }
        }
        @helper EditBox(MvcHtmlString label, MvcHtmlString editor, MvcHtmlString validation)
        {
            <div class="form-group">
                @label
                <div class="col-md-9">
                    @editor
                    @validation
                </div>
            </div>
         }

    调用: 

    @EditBoxFor(Html, model => model.Agent, true)

  • 相关阅读:
    提升网页访问速度
    npm模块之http-proxy-middleware使用教程
    Spring MVC详解
    angular ng-select ng-option
    grunt uglify 去掉console.log
    window.open
    spring学习
    requirejs 入门【链接】
    IOS上iframe的滚动条失效的解决办法
    优秀技术链接
  • 原文地址:https://www.cnblogs.com/nirvanan/p/11951868.html
Copyright © 2020-2023  润新知