コード例 #1
0
        /// <summary>
        /// Creates the html required for a button.
        /// </summary>
        /// <param name="text">The text to display in the button.</param>
        /// <param name="buttonType">The type of button to render.</param>
        /// <param name="type">The button type attribute value.</param>
        /// <param name="id">The id to use on the button.</param>
        /// <param name="classes">The classes to use on the button.</param>
        /// <returns>The html of the generated button.</returns>
        private static MvcHtmlString RenderButton(string text, ButtonType buttonType, string type, string id, string classes, string formId = null)
        {
            string button = "<button";

            if (string.IsNullOrEmpty(id) == false)
            {
                button += " id=\"" + id + "\"";
            }

            classes = ("button " + buttonType.GetDisplayText() + " " + (classes ?? "")).Trim();

            button += " class=\"" + classes + "\"";

            if (formId != null)
            {
                button += " onclick=\"$('#" + formId + "').submit()\"";
            }

            button += " type=\"" + type + "\">" + text + " </button>";

            return(new MvcHtmlString(button));
        }