PageRenderTime 24ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

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