Пример #1
0
        public static MvcHtmlString ManipulationButton <VM, T>(
            this HtmlHelper <VM> htmlHelper,
            ManipulationButtonType manipulationButtonType,
            string textOrUrl,
            Expression <Func <VM, T> > target,
            string name = null,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            string targetName = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(
                                                               ExpressionHelper.GetExpressionText(target)));

            return
                (ManipulationButton <VM>(
                     htmlHelper,
                     manipulationButtonType,
                     textOrUrl,
                     targetName,
                     name,
                     manipulationButtonStyle,
                     htmlAttributes));
        }
Пример #2
0
        protected MvcHtmlString BaseButton(string displayName,
                                           ManipulationButtonStyle buttonStyle, IDictionary <string, object> htmlAttributes)
        {
            switch (buttonStyle)
            {
            case ManipulationButtonStyle.Button:
                return(MvcHtmlString.Create
                       (
                           string.Format("<input type=\"button\" value=\"{0}\" {1} />",
                                         CurrHtmlHelper.Encode(displayName),
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));

            case ManipulationButtonStyle.Image:
                htmlAttributes["src"] = displayName;
                BasicHtmlHelper.SetDefaultStyle(htmlAttributes, "cursor", "pointer");
                return(MvcHtmlString.Create
                       (
                           string.Format("<img {1} />",
                                         displayName,
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));

            default:
                htmlAttributes["href"] = "javascript:void(0);";
                return(MvcHtmlString.Create
                       (
                           string.Format("<a {1}>{0}</a>",
                                         CurrHtmlHelper.Encode(displayName),
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes))
                       ));
            }
        }
Пример #3
0
 public static MvcHtmlString SortableListDeleteButton <VM>(
     this HtmlHelper <VM> htmlHelper,
     string textOrUrl,
     ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
     IDictionary <string, object> htmlAttributes     = null)
 {
     return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl, string.Format("MvcControlsToolkit_SortableList_Click(\"{0}\", \"ManipulationButtonRemove\");", htmlHelper.PrefixedId("Container")),
                                          htmlHelper.PrefixedId("Remove"), manipulationButtonStyle, htmlAttributes));
 }
Пример #4
0
 public MvcHtmlString ClearSelectionButton(string displayName, ManipulationButtonStyle buttonStyle = ManipulationButtonStyle.Button, IDictionary <string, object> htmlAttributes = null)
 {
     if (htmlAttributes == null)
     {
         htmlAttributes = new Dictionary <string, object>(2);
     }
     htmlAttributes.Add("onclick", string.Format(
                            "javascript:return DualSelect_MoveAll('{0}', false)", controlId));
     return(BaseButton(displayName, buttonStyle, htmlAttributes));
 }
Пример #5
0
        public static MvcHtmlString TreeViewToggleEditButtonFor <VM, T>(
            this HtmlHelper <VM> htmlHelper,
            Expression <Func <VM, IEnumerable <T> > > expression,
            string textOrUrlEdit,
            string cssClassEdit,
            string textOrUrlUndoEdit,
            string cssClassUndoEdit,
            string textOrUrlRedoEdit,
            string cssClassRedoEdit,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button)
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }

            if (textOrUrlEdit == null)
            {
                throw (new ArgumentNullException("textOrUrlEdit"));
            }
            if (cssClassEdit == null)
            {
                throw (new ArgumentNullException("cssClassEdit"));
            }

            if (textOrUrlUndoEdit == null)
            {
                throw (new ArgumentNullException("textOrUrlUndoEdit"));
            }
            if (cssClassUndoEdit == null)
            {
                throw (new ArgumentNullException("cssClassUndoEdit"));
            }

            if (textOrUrlRedoEdit == null)
            {
                throw (new ArgumentNullException("textOrUrlRedoEdit"));
            }
            if (cssClassRedoEdit == null)
            {
                throw (new ArgumentNullException("cssClassRedoEdit"));
            }

            if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient)
            {
                return(MvcHtmlString.Create(string.Empty));
            }
            string id = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression)));

            return(MvcHtmlString.Create(
                       string.Format(initializeToggleEditButtonScript, id, textOrUrlEdit, cssClassEdit, textOrUrlUndoEdit, cssClassUndoEdit, textOrUrlRedoEdit, cssClassRedoEdit) +
                       htmlHelper.ManipulationButton(ManipulationButtonType.Custom, string.Empty,
                                                     string.Format(toggleEditButtonScript, id, textOrUrlEdit, cssClassEdit, textOrUrlUndoEdit, cssClassUndoEdit, textOrUrlRedoEdit, cssClassRedoEdit),
                                                     id + "_ToggleEditButton", manipulationButtonStyle, null).ToString()));
        }
Пример #6
0
        public static MvcHtmlString TreeViewDeleteButton <VM>(
            this HtmlHelper <VM> htmlHelper,
            string textOrUrl,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null,
            string name = null)
        {
            string id = htmlHelper.PrefixedId("Container");

            return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl,
                                                 string.Format(removeButtonScript, id), name == null ? id + "_RemoveButton" : name, manipulationButtonStyle, htmlAttributes));
        }
Пример #7
0
        public static MvcHtmlString TreeViewAddButton <VM>(
            this HtmlHelper <VM> htmlHelper,
            int templateToUse,
            string textOrUrl,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null,
            string name = null)
        {
            if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient)
            {
                return(MvcHtmlString.Create(string.Empty));
            }
            string id = htmlHelper.PrefixedId("ItemsContainer");

            return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl,
                                                 string.Format(addButtonScript, id, templateToUse), name == null ? id + "_AddButton" + templateToUse.ToString() : name, manipulationButtonStyle, htmlAttributes));
        }
Пример #8
0
        public static MvcHtmlString SortableListAddButtonFor <VM, TItem>(
            this HtmlHelper <VM> htmlHelper,
            RenderInfo <IEnumerable <TItem> > renderInfo,
            string textOrUrl,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null,
            string name       = null,
            int templateIndex = 0)
        {
            if (renderInfo == null)
            {
                throw (new ArgumentNullException("renderInfo"));
            }
            if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient)
            {
                return(MvcHtmlString.Create(string.Empty));
            }
            string id = BasicHtmlHelper.IdFromName(renderInfo.Prefix);

            return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl,
                                                 string.Format(addButtonScript, id, templateIndex), name == null ? id + "_AddButton" + templateIndex.ToString(CultureInfo.InvariantCulture) : name, manipulationButtonStyle, htmlAttributes));
        }
Пример #9
0
        public static MvcHtmlString SortableListAddButtonFor <VM, T>(
            this HtmlHelper <VM> htmlHelper,
            Expression <Func <VM, IEnumerable <T> > > expression,
            string textOrUrl,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null,
            string name       = null,
            int templateIndex = 0)
        {
            if (expression == null)
            {
                throw (new ArgumentNullException("expression"));
            }
            if (MvcEnvironment.Validation(htmlHelper) == ValidationType.StandardClient)
            {
                return(MvcHtmlString.Create(string.Empty));
            }
            string id = BasicHtmlHelper.IdFromName(htmlHelper.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression)));

            return(htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl,
                                                 string.Format(addButtonScript, id, templateIndex), name == null ? id + "_AddButton" + templateIndex.ToString(CultureInfo.InvariantCulture) : name, manipulationButtonStyle, htmlAttributes));
        }
Пример #10
0
        public static MvcHtmlString ManipulationButton <VM>(
            this HtmlHelper <VM> htmlHelper,
            ManipulationButtonType manipulationButtonType,
            string textOrUrl,
            string targetName,
            string name = null,
            ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary <string, object> htmlAttributes     = null)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                name = getManipulationButtonClass(manipulationButtonType);
            }
            if (textOrUrl == null)
            {
                throw new ArgumentNullException("textOrUrl");
            }
            if (targetName == null)
            {
                throw new ArgumentNullException("targetName");
            }

            if (htmlAttributes == null)
            {
                htmlAttributes = new Dictionary <string, object>();
            }

            string buttonId = BasicHtmlHelper.IdFromName(
                BasicHtmlHelper.AddField(htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix, name));

            htmlAttributes["id"] = buttonId;
            switch (manipulationButtonStyle)
            {
            case ManipulationButtonStyle.Button:
                htmlAttributes["type"]  = "button";
                htmlAttributes["value"] = htmlHelper.Encode(textOrUrl);
                return(MvcHtmlString.Create(
                           string.Format(buttonSchema,
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes),
                                         processTarget(manipulationButtonType, targetName),
                                         getManipulationButtonClass(manipulationButtonType),
                                         buttonId)));

            case ManipulationButtonStyle.Link:
                htmlAttributes["href"] = "javascript:void(0);";
                return(MvcHtmlString.Create(
                           string.Format(linkSchema,
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes),
                                         processTarget(manipulationButtonType, targetName),
                                         getManipulationButtonClass(manipulationButtonType),
                                         buttonId,
                                         htmlHelper.Encode(textOrUrl))));

            default:
                htmlAttributes["src"] = textOrUrl;
                BasicHtmlHelper.SetDefaultStyle(htmlAttributes, "cursor", "pointer");
                return(MvcHtmlString.Create(
                           string.Format(imgSchema,
                                         BasicHtmlHelper.GetAttributesString(htmlAttributes),
                                         processTarget(manipulationButtonType, targetName),
                                         getManipulationButtonClass(manipulationButtonType),
                                         buttonId)));
            }
        }/*