示例#1
0
        public static IHtmlContent PassWordFormGroupInputFor <TModel, TValue>(
            this IHtmlHelper <TModel> htmlHelper,
            Expression <Func <TModel, TValue> > property,
            string placeholder,
            object labelAttributes   = null,
            object textBoxAttributes = null,
            bool localValidation     = true)
        {
            using (var writer = new StringWriter())
            {
                writer.Write("<div class='form-group'>");
                HtmlHelperLabelExtensions.LabelFor(
                    htmlHelper,
                    property,
                    labelAttributes)
                .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);

                HtmlHelperInputExtensions.TextBoxFor(
                    htmlHelper,
                    property,
                    textBoxAttributes ?? new { placeholder, @class = "form-control", @type = "password" })
                .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);

                if (localValidation)
                {
                    HtmlHelperValidationExtensions.ValidationMessageFor(
                        htmlHelper,
                        property)
                    .WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
                }
                writer.Write("</div>");
                return(new HtmlString(writer.ToString()));
            }
        }
示例#2
0
        private static IHtmlContent GenerateLabel <TModel, TValue>(IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, IHtmlContent label)
        {
            IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, expression);
            string       result   = String.Concat("<div class=\"form-group\">",
                                                  GetString(label),
                                                  "<div class=\"col-md-8\"  style=\"padding:6px 12px\" >",
                                                  GetString(contents),
                                                  "</div>",
                                                  GetString(HtmlHelperInputExtensions.HiddenFor(html, expression)),
                                                  "</div>");

            return(new HtmlString(result));
        }
示例#3
0
        public IHtmlContent Text <TResult>(Expression <Func <TModel, TResult> > expression)
        {
            return(HtmlHelperInputExtensions.TextBoxFor(html, expression));

            //var result = new HtmlString("");

            //using (var writer = new StringWriter())
            //{
            //    result.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
            //    br.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);

            //}
            ////result.WriteTo()
            ////result.WriteTo()
            //return result;
        }
示例#4
0
        public static IHtmlContent RPCSEditorFor <TModel, TValue>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue> > expression, OperationSet EditorRights, OperationSet displayRights, string toolTip = "", string errorMessage = "")
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, expression, new { @class = "control-label col-md-4" });

            if (appUserSvc.HasAccess(EditorRights))
            {
                return(GenerateEditor(html, expression, toolTip, errorMessage, label));
            }

            if (appUserSvc.HasAccess(displayRights))
            {
                return(GenerateLabel(html, expression, label));
            }

            return(HtmlHelperInputExtensions.HiddenFor(html, expression));
        }
示例#5
0
        public static IHtmlContent RPCSDropDownList <TModel, TValue1, TValue2>(this IHtmlHelper <TModel> html, Expression <Func <TModel, TValue1> > labelExpression, Expression <Func <TModel, TValue2> > valueExpression, string name,
                                                                               IEnumerable <SelectListItem> selectList, OperationSet editRights, OperationSet displayRights)
        {
            var appUserSvc = _serviceProvider.GetRequiredService <IApplicationUserService>();

            IHtmlContent label = HtmlHelperLabelExtensions.LabelFor(html, labelExpression, new { @class = "control-label col-md-4" });

            if (appUserSvc.HasAccess(editRights))
            {
                var contents = HtmlHelperSelectExtensions.DropDownList(html, name, selectList, new { @class = "form-control" });

                string result = String.Concat("<div class=\"form-group\">",
                                              GetString(label),
                                              "<div class=\"col-md-8\">",
                                              GetString(contents),
                                              "</div>",
                                              "</div>");
                return(new HtmlString(result));
            }
            if (appUserSvc.HasAccess(displayRights))
            {
                IHtmlContent contents = HtmlHelperDisplayExtensions.DisplayFor(html, valueExpression);
                string       result   = String.Concat("<div class=\"form-group\">",
                                                      GetString(label),
                                                      "<div class=\"col-md-8\">",
                                                      GetString(contents),
                                                      "</div>",
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression)),
                                                      GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression)),
                                                      "</div>");
                return(new HtmlString(result));
            }
            string v = GetString(HtmlHelperInputExtensions.HiddenFor(html, valueExpression));
            string l = GetString(HtmlHelperInputExtensions.HiddenFor(html, labelExpression));

            return(new HtmlString(v + l));
        }
示例#6
0
 public static IHtmlContent TextBoxFor <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, string format, IDictionary <string, object> htmlAttributes)
 {
     Methods.SetCommonAttributes(htmlHelper, expression, ref htmlAttributes);
     return(HtmlHelperInputExtensions.TextBoxFor(htmlHelper, expression, htmlAttributes));
 }