/pigeoncms/Modules/PigeonCms.ItemsSearch/views/ItemsSearch.ascx.cs

http://pigeoncms.googlecode.com/ · C# · 94 lines · 81 code · 10 blank · 3 comment · 6 complexity · 022a623b8188d04e39ea814891722379 MD5 · raw file

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Web.Caching;
  12. using PigeonCms;
  13. using System.Collections.Generic;
  14. using System.Text;
  15. public partial class Controls_ItemsSearch : PigeonCms.BaseModuleControl
  16. {
  17. private int minSearchChars = 0;
  18. public int MinSearchChars
  19. {
  20. get { return GetIntParam("MinSearchChars", minSearchChars); }
  21. set { minSearchChars = value; }
  22. }
  23. private int itemsTarget = 0;
  24. public int ItemsTarget
  25. {
  26. get { return GetIntParam("ItemsTarget", itemsTarget); }
  27. set { itemsTarget = value; }
  28. }
  29. private string headerText = "";
  30. public string HeaderText
  31. {
  32. get { return GetStringParam("HeaderText", headerText); }
  33. set { headerText = value; }
  34. }
  35. private string footerText = "";
  36. public string FooterText
  37. {
  38. get { return GetStringParam("FooterText", footerText); }
  39. set { footerText = value; }
  40. }
  41. private string search = "";
  42. public string Search
  43. {
  44. get { return GetStringParam("Search", search, "search"); }
  45. set { search = value; }
  46. }
  47. protected void Page_Load(object sender, EventArgs e)
  48. {
  49. if (!Page.IsPostBack)
  50. {
  51. TxtSearch.Text = this.Search;
  52. }
  53. }
  54. protected void BtnSearch_Click(object sender, EventArgs e)
  55. {
  56. string url = "";
  57. bool allow = true;
  58. if (TxtSearch.Text.Length < this.MinSearchChars)
  59. allow = false;
  60. if (allow)
  61. {
  62. PigeonCms.Menu menuTarget = null;
  63. if (this.ItemsTarget > 0)
  64. {
  65. if (menuTarget == null)
  66. {
  67. menuTarget = new MenuManager().GetByKey(this.ItemsTarget);
  68. }
  69. try
  70. {
  71. url = Utility.GetRoutedUrl(menuTarget, "search=" + TxtSearch.Text, true);
  72. //if (menuTarget.RoutePattern.Contains("{itemname}"))
  73. // res = Utility.GetRoutedUrl(
  74. // menuTarget, new RouteValueDictionary { { "itemname", item.Title } }, "", true);
  75. Response.Redirect(url);
  76. }
  77. catch (Exception ex)
  78. {
  79. Tracer.Log("GetLinkAddress(): " + ex.ToString(), TracerItemType.Error);
  80. }
  81. }
  82. }
  83. }
  84. }