/// <summary> /// Renders a button which provides an <input> (type=submit) tag (target: controller Http-Post method) /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="htmlHelper"></param> /// <param name="type"></param> /// <param name="text"></param> /// <param name="actionName"></param> /// <param name="controllerName"></param> /// <param name="id"></param> /// <returns></returns> // ReSharper disable once UnusedParameter.Global public static MvcHtmlString SubmitButton <TModel>(this HtmlHelper <TModel> htmlHelper, ButtonType type, string text) { var htmlAttributes = HtmlExtensions.GetButtonHtmlAttributes(type); var b = new TagBuilder("input"); b.MergeAttribute("type", "submit"); b.MergeAttribute("value", text); b.MergeAttributes <string, object>(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)); var s = new MvcHtmlString(b.ToString(TagRenderMode.SelfClosing)); return(s); }
/// <summary> /// Renders a button which provides an <a> tag (target: controller Http-Get method) /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="htmlHelper"></param> /// <param name="type"></param> /// <param name="text"></param> /// <param name="actionName"></param> /// <param name="controllerName"></param> /// <param name="id"></param> /// <returns></returns> public static MvcHtmlString LinkButton <TModel>(this HtmlHelper <TModel> htmlHelper, ButtonType type, string text, [AspMvcAction] string actionName, [AspMvcController] string controllerName = null, object id = null) { var htmlAttributes = HtmlExtensions.GetButtonHtmlAttributes(type); if (id != null) { object routeValues = new { id = id }; return(htmlHelper.ActionLink(text, actionName, controllerName, routeValues, htmlAttributes)); } else { return(htmlHelper.ActionLink(text, actionName, controllerName, htmlAttributes)); } }