/// <summary> /// Creates the HTML for a submit <input> (or optionally <button>) that submits a value in the form post when clicked. /// </summary> /// <remarks> /// Uses an <input> by default so the submitted value works in IE7. /// <see cref="http://rommelsantor.com/clog/2012/03/12/fixing-the-ie7-submit-value/"/> /// </remarks> /// <param name="name">The name (and id - use htmlAttributes to overwrite) of the element</param> /// <param name="value">The value to submit with the form</param> /// <param name="buttonText">If you want to use a <button> rather than <input> then specify this to set the text the user sees</param> /// <param name="htmlAttributes">Any HTML attributes that should be applied to the button</param> /// <returns>The HTML for the submit button</returns> public Nancy.ViewEngines.Razor.IHtmlString Submit(string name, string value, Nancy.ViewEngines.Razor.IHtmlString buttonText = null, HtmlAttributes htmlAttributes = null) { if (buttonText != null) { return(HtmlCreator.BuildButton(buttonText, "submit", name, value, htmlAttributes)); } return(HtmlCreator.BuildInput(name, value, "submit", htmlAttributes)); }
/// <inheritdoc /> /// <remarks> /// Uses an <input> by default so the submitted value works in IE7. /// See http://rommelsantor.com/clog/2012/03/12/fixing-the-ie7-submit-value/ /// </remarks> public virtual IHtmlContent Button(IHtmlContent content, string type, string id, string value, HtmlAttributes htmlAttributes) { if (content == null && value == null) { throw new ArgumentNullException("content", "Expected one of content or value to be specified"); } if (content == null) { return(HtmlCreator.BuildInput(id, value, type ?? "button", htmlAttributes)); } return(HtmlCreator.BuildButton(content, type, id, value, htmlAttributes)); }
public void Generate_input_without_name() { var h = HtmlCreator.BuildInput(null, "value&", "submit", new HtmlAttributes().AddClass("lol")); HtmlApprovals.VerifyHtml(h.ToHtmlString()); }