Example #1
0
        public static MvcHtmlString ResetButtonCr(this HtmlHelper helper, string id, string name, string text, string style, object htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("input");

            Dictionary <string, object> attributes = new Dictionary <string, object>();

            attributes.Add("type", Enum.GetName(typeof(ButtonKind), ButtonKind.reset));

            attributes.Add("id", id);

            attributes.Add("value", text);

            if (!string.IsNullOrEmpty(name))
            {
                attributes.Add("name", name);
            }

            if (!string.IsNullOrEmpty(style))
            {
                attributes.Add("Style", style);
            }

            HtmlModifier.ManageHtmlAttributes(attributes, StyleKind.Button);

            builder.MergeAttributes(attributes);

            if (htmlAttributes != null)
            {
                var objAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

                builder.MergeAttributes(objAttributes);
            }

            return(MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing)));
        }
Example #2
0
        public static MvcHtmlString TextBoxCrFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, object htmlAttributes)
        {
            Dictionary <string, object> attributes = new Dictionary <string, object>(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes));

            HtmlModifier.ManageHtmlAttributes(attributes, StyleKind.TextBox);
            return(System.Web.Mvc.Html.InputExtensions.TextBoxFor <TModel, TProperty>(helper, expression, attributes));
        }
Example #3
0
        /// <summary>
        ///It is not a helper, but just a method to create Icon button
        /// </summary>
        /// <param name="id"></param>
        /// <param name="text"></param>
        /// <param name="buttonCssClass"></param>
        /// <param name="iconCssClass"></param>
        /// <param name="script"></param>
        /// <returns></returns>
        internal static MvcHtmlString IconButton(string id, string text, string buttonCssClass, string iconCssClass, string script)
        {
            TagBuilder ButtonBuilder = new TagBuilder("a");

            if (id.HasValue())
            {
                ButtonBuilder.MergeAttribute("id", HtmlModifier.ModifyId(id));
            }

            ButtonBuilder.AddCssClass(buttonCssClass);

            TagBuilder IconBuilder = new TagBuilder("span");

            IconBuilder.AddCssClass(iconCssClass);

            ButtonBuilder.InnerHtml = IconBuilder.ToString();

            if (text.HasValue())
            {
                ButtonBuilder.SetInnerText(text);
            }

            if (script.HasValue())
            {
                ButtonBuilder.InnerHtml += script;
            }

            return(MvcHtmlString.Create(ButtonBuilder.ToString()));
        }
Example #4
0
        public static MvcHtmlString PasswordCrFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <System.Func <TModel, TProperty> > expression
                                                                      , Dictionary <string, object> htmlAttributes, bool checkStrength)
        {
            htmlAttributes = htmlAttributes ?? new Dictionary <string, object>();

            HtmlModifier.ManageHtmlAttributes(htmlAttributes, StyleKind.TextBox);

            if (checkStrength)
            {
                htmlAttributes.Add("onkeyup", "strenghtChecker(this)");
                htmlAttributes.Add("onblur", "hideChecker($(this).next('span'))");
            }

            var memberExp = expression.Body as MemberExpression;

            var strengthChecker = memberExp.Member.GetCustomAttributes(typeof(StrengthChecker), true);

            if (strengthChecker.Length > 0)
            {
                PasswordChecker validation = new PasswordChecker();

                foreach (var item in validation.CreateRelatedValidation())
                {
                    htmlAttributes.Add(item.Key, item.Value);
                }
            }

            var htmlPassword = System.Web.Mvc.Html.InputExtensions.PasswordFor(helper, expression, htmlAttributes);

            TagBuilder stateBuilder = new TagBuilder("span");

            return(MvcHtmlString.Create(htmlPassword.ToHtmlString() + stateBuilder));
        }
Example #5
0
 internal static void ManageAttributesWithPermissions(Dictionary <string, object> attributes, string kendoStyle, bool disable)
 {
     if (disable)
     {
         attributes.Add("Style", "opacity:0.4");
         attributes.Add("disabled", "disabled");
     }
     HtmlModifier.ManageHtmlAttributes(attributes, disable ? string.Empty : kendoStyle);
 }
Example #6
0
        public static MvcHtmlString CheckBoxCrFor <TModel>(this HtmlHelper <TModel> helper, Expression <System.Func <TModel, bool> > expression, string id, Dictionary <string, object> htmlAttributes)
        {
            htmlAttributes = htmlAttributes ?? new Dictionary <string, object>();

            if (id.HasValue())
            {
                htmlAttributes.Add("id", id);
            }

            HtmlModifier.ManageHtmlAttributes(htmlAttributes, StyleKind.checkBox);

            return(System.Web.Mvc.Html.InputExtensions.CheckBoxFor(helper, expression, htmlAttributes));
        }
Example #7
0
        public static MvcHtmlString ButtonCr(this HtmlHelper helper, string id, string name, string text, bool isConfirmButton, string style, object htmlAttributes, bool disable = false)
        {
            TagBuilder builder = new TagBuilder("input");

            Dictionary <string, object> attributes = new Dictionary <string, object>();

            attributes.Add("type", Enum.GetName(typeof(ButtonKind), ButtonKind.button));

            attributes.Add("id", id);

            if (!string.IsNullOrEmpty(name))
            {
                attributes.Add("name", name);
            }

            attributes.Add("value", text);

            if (!string.IsNullOrEmpty(style))
            {
                attributes.Add("Style", style);
            }

            if (isConfirmButton)
            {
                attributes.Add("default", "");
            }

            HtmlModifier.ManageAttributesWithPermissions(attributes, StyleKind.Button, disable);

            builder.MergeAttributes(attributes);

            if (htmlAttributes != null)
            {
                if (htmlAttributes.GetType() == typeof(Dictionary <string, object>))
                {
                    builder.MergeAttributes((Dictionary <string, object>)htmlAttributes);
                }
                else
                {
                    var objAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
                    builder.MergeAttributes(objAttributes);
                }
            }



            return(MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing)));
        }
Example #8
0
        public static MvcHtmlString ImageLinkButtonCr(this HtmlHelper helper, string id, string text, string url, string imagePath, string buttonCssClass, string script)
        {
            TagBuilder ButtonBuilder = new TagBuilder("a");

            if (id.HasValue())
            {
                ButtonBuilder.MergeAttribute("id", HtmlModifier.ModifyId(id));
            }

            if (text.HasValue())
            {
                ButtonBuilder.SetInnerText(text);
            }

            if (url.HasValue())
            {
                ButtonBuilder.Attributes.Add("href", url);
            }

            if (buttonCssClass.HasValue())
            {
                ButtonBuilder.AddCssClass(buttonCssClass);
            }
            else
            {
                ButtonBuilder.AddCssClass(StyleKind.Button);
            }


            TagBuilder IconBuilder = new TagBuilder("img");

            IconBuilder.AddCssClass(StyleKind.Icons.Icon);

            IconBuilder.Attributes.Add("src", imagePath);

            ButtonBuilder.InnerHtml += IconBuilder.ToString(TagRenderMode.SelfClosing);

            if (script.HasValue())
            {
                ButtonBuilder.InnerHtml += script;
            }

            return(MvcHtmlString.Create(ButtonBuilder.ToString()));
        }
Example #9
0
        public static MvcHtmlString PasswordCr(this HtmlHelper helper, string id, string name, string cssClass, string style, bool readOnly, Dictionary <string, object> htmlAttributes)
        {
            htmlAttributes = htmlAttributes ?? new Dictionary <string, object>();
            htmlAttributes.Add("id", id);
            if (!string.IsNullOrEmpty(style))
            {
                htmlAttributes.Add("Style", style);
            }
            if (readOnly)
            {
                htmlAttributes.Add("readOnly", readOnly);
            }
            if (!string.IsNullOrEmpty(cssClass))
            {
                htmlAttributes.Add("class", cssClass);
            }

            HtmlModifier.ManageHtmlAttributes(htmlAttributes, StyleKind.TextBox);

            return(System.Web.Mvc.Html.InputExtensions.Password(helper, name, string.Empty, htmlAttributes));
        }
Example #10
0
        public static MvcHtmlString IconButtonCr(this HtmlHelper helper, string id, string text, string buttonCssClass, string iconCssClass, string script)
        {
            TagBuilder ButtonBuilder = new TagBuilder("a");

            if (id.HasValue())
            {
                ButtonBuilder.MergeAttribute("id", HtmlModifier.ModifyId(id));
            }

            if (text.HasValue())
            {
                ButtonBuilder.SetInnerText(text);
            }

            if (buttonCssClass.HasValue())
            {
                ButtonBuilder.AddCssClass(buttonCssClass);
            }
            else
            {
                ButtonBuilder.AddCssClass(StyleKind.Button);
            }

            TagBuilder IconBuilder = new TagBuilder("span");

            IconBuilder.AddCssClass(iconCssClass);

            ButtonBuilder.InnerHtml += IconBuilder.ToString();

            if (script.HasValue())
            {
                ButtonBuilder.InnerHtml += script;
            }

            return(MvcHtmlString.Create(ButtonBuilder.ToString()));
        }
Example #11
0
 public static MvcHtmlString TextBoxCrFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <System.Func <TModel, TProperty> > expression)
 {
     return(System.Web.Mvc.Html.InputExtensions.TextBoxFor <TModel, TProperty>(helper, expression, HtmlModifier.ManageHtmlAttributes(StyleKind.TextBox)));
 }
Example #12
0
        public static MvcHtmlString TextAreaCrFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <System.Func <TModel, TProperty> > expression, Dictionary <string, object> htmlAttributes)
        {
            HtmlModifier.ManageHtmlAttributes(htmlAttributes, StyleKind.TextBox);

            return(System.Web.Mvc.Html.TextAreaExtensions.TextAreaFor <TModel, TProperty>(helper, expression, htmlAttributes));
        }