예제 #1
0
        public static MvcHtmlString GovUkPostCodeInputFor <TModel, TProperty>(
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TProperty> > expression,
            string buttonText        = null,
            bool hideLabel           = false,
            bool hasCustomValidation = false)
        {
            var validationAttributes = htmlHelper.GetValidationAttributes(expression);
            var hasValidation        = hasCustomValidation || validationAttributes.Count > 0;

            var html = new StringBuilder();

            html.Append(TextInputHtml.GenerateCustomTextInputFor(htmlHelper, expression, new { @class = "form-control form-control-1-8 post-code" }, validationAttributes));

            if (!string.IsNullOrEmpty(buttonText))
            {
                html.Append(string.Format(" <input type=\"submit\" id=\"FindAddress\" name=\"FindAddress\" class=\"button\" value=\"{0}\">", buttonText));
            }

            return(ControlContainerHtml.GenerateSingleContainer(
                       htmlHelper,
                       expression,
                       new MvcHtmlString(html.ToString()),
                       hideLabel,
                       hasValidation));
        }
예제 #2
0
        public static MvcHtmlString GovUkCustomTextInputFor <TModel, TProperty>(
            this HtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TProperty> > expression,
            object customFieldAttributes,
            bool hideLabel           = false,
            bool hasCustomValidation = false)
        {
            var validationAttributes = htmlHelper.GetValidationAttributes(expression);
            var hasValidation        = hasCustomValidation || validationAttributes.Count > 0;

            return(ControlContainerHtml.GenerateSingleContainer(
                       htmlHelper,
                       expression,
                       TextInputHtml.GenerateCustomTextInputFor(htmlHelper, expression, customFieldAttributes, validationAttributes),
                       hideLabel,
                       hasValidation));
        }