using System; using System.Collections.Generic; using System.Text; using System.Web.Mvc; using System.Web.Mvc.Html; using Kreta.Resources; namespace Kreta.Web.Helpers { public static class SearchPanelSideBarExtensions { public static SearchPanelSideBarHelper SearchPanelSideBar(this HtmlHelper helper, string formId, string gridId, string preSubmitFunction = null, string postSubmitFunction = null, Dictionary htmlAttributes = null) { if (htmlAttributes == null) { htmlAttributes = new Dictionary(); } htmlAttributes.Add("id", formId); helper.SearchPanelSideBarStart(formId, gridId, preSubmitFunction, postSubmitFunction); helper.BeginForm(null, null, FormMethod.Get, htmlAttributes); return new SearchPanelSideBarHelper(helper); } public static void SearchPanelSideBarStart(this HtmlHelper html, string formId, string gridId, string preSubmitFunction, string postSubmitFunction) { StringBuilder beforeContent = new StringBuilder(); beforeContent.AppendFormat("
", gridId); beforeContent.Append("
"); beforeContent.Append("
"); beforeContent.Append(""); beforeContent.Append(""); beforeContent.Append("
"); beforeContent.Append("
"); beforeContent.Append(""); html.ViewContext.Writer.Write(beforeContent.ToString()); } public static void SearchPanelSideBarEnd(this HtmlHelper html) { StringBuilder endContent = new StringBuilder(); endContent.Append("
"); endContent.Append("
"); endContent.Append("
"); endContent.Append(""); html.ViewContext.Writer.Write(endContent.ToString()); } public class SearchPanelSideBarHelper : IDisposable { private readonly HtmlHelper rohtml; public SearchPanelSideBarHelper(HtmlHelper html) { rohtml = html; } public void Dispose() { rohtml.SearchPanelSideBarEnd(); } } } }