using System; using System.Collections.Generic; using System.Text; using System.Web.Mvc; using System.Web.Mvc.Html; using Kreta.Framework; namespace Kreta.Web.Helpers { public static class SearchPanelExtensions { public static SearchPanelHelper SearchPanel(this HtmlHelper helper, string formId, string gridId, int columnNumber = 1, bool autoOpen = false, string actionName = "ReloadGrid", Dictionary htmlAttributes = null) { if (htmlAttributes == null) { htmlAttributes = new Dictionary(); htmlAttributes.Add("id", formId); htmlAttributes.Add("columnNumber", columnNumber); } string btnValue = StringResourcesUtil.GetString(238); string btnId = formId + "Btn"; helper.SearchPanelStart(autoOpen); var mvcForm = helper.BeginForm(null, null, FormMethod.Get, htmlAttributes); StringBuilder sb = new StringBuilder(); sb .Append(""); helper.ViewContext.Writer.Write(sb.ToString()); return new SearchPanelHelper(helper); } public static void SearchPanelStart(this HtmlHelper html, bool autoOpen) { string searchPanelText = StringResourcesUtil.GetString(226); StringBuilder beforeContent = new StringBuilder(); if (autoOpen) beforeContent.Append("
  • ").Append(searchPanelText).Append("
    "); else beforeContent.Append("
    • ").Append(searchPanelText).Append("
      "); html.ViewContext.Writer.Write(beforeContent.ToString()); } public static void SearchPanelEnd(this HtmlHelper html) { StringBuilder endContent = new StringBuilder(); endContent.Append("
    "); html.ViewContext.Writer.Write(endContent.ToString()); } public class SearchPanelHelper : IDisposable { private readonly HtmlHelper rohtml; public SearchPanelHelper(HtmlHelper html) { rohtml = html; } public void Dispose() { rohtml.SearchPanelEnd(); } } } }