/// <summary> /// Remove an input from the dictionary /// </summary> public void RemoveInput(InputBase input) { if (inputs.ContainsKey(input.UniqueID)) { inputs.Remove(input.UniqueID); } }
/// <summary> /// Update the inputs from the client /// </summary> /// <param name="cgivars">name-value pairs</param> private void OnPost(Dictionary <string, string> cgivars) { foreach (var pair in cgivars) { if (inputs.ContainsKey(pair.Key)) { // try to set the value of the input try { InputBase input = inputs[pair.Key]; input.SetValue(pair.Value); } catch (Exception e) { Debug.WriteLine(e.ToString()); } } } }
/// <summary> /// Add an input to the dictionary /// </summary> /// <param name="input">form input</param> public void AddInput(InputBase input) { if (!inputs.ContainsKey(input.UniqueID)) { if (null != restoredInputs) { foreach (SavedValue i in restoredInputs) { if (i.UniqueID == input.UniqueID) { // restore value input.SetValue(i.Value); break; } } } inputs.Add(input.UniqueID, input); } }
/// <summary> /// Get specified form /// </summary> /// <param name="formName">name of form</param> /// <returns>html</returns> private string GetFormPage(string formName) { HtmlBuilder b = new HtmlBuilder(); b.open("html"); b.open("head"); b.open("title"); b.append(b.text(formName)); b.close("title"); b.open("style", b.attr("type", "text/css")); b.append("th {text-align: right;}\n"); b.append("td {padding-left: 1em; text-align: left;}\n"); b.close("style"); b.include_js("scripts/slider.js"); b.include_css("styles/slider.css"); b.open("script", b.attr("type", "text/javascript")); b.append("function doclick(sel){\n"); b.append(" sel.value=\"True\";\n"); b.append(" sel.form.submit();\n"); b.append("}\n"); b.close("script"); b.close("head"); b.open("body"); b.open("h2"); b.append(b.text(formName)); b.close("h2"); b.hr(); b.open("form", b.attr("name", formName, "action", b.fmt("{0}.cgi", formName), "method", "post")); b.open("table"); foreach (var pair in inputs) { InputBase input = pair.Value; if (input.Form.Name == formName) { b.append(input.GetHtml()); } } b.open("tr"); b.open("th"); b.close("th"); b.open("td"); FormSettings form = GetForm(formName); if (!form.AutoSubmit) { b.open("input", b.attr("type", "submit", "value", "SUBMIT")); b.close("input"); b.open("input", b.attr("type", "reset", "value", "RESET")); b.close("input"); } b.close("td"); b.close("tr"); b.close("table"); b.close("form"); // required "linkware" credits b.hr(); //b.link("http://carpe.ambiprospect.com/slider/", "sliders by CARPE Design"); return(b.ToString()); }