1
/****************************************************************************
3
| Copyright (c) 2007 Novell, Inc.
6
| This program is free software; you can redistribute it and/or
7
| modify it under the terms of version 2 of the GNU General Public License as
8
| published by the Free Software Foundation.
10
| This program is distributed in the hope that it will be useful,
11
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
| GNU General Public License for more details.
15
| You should have received a copy of the GNU General Public License
16
| along with this program; if not, contact Novell, Inc.
18
| To contact Novell about this file by physical or electronic mail,
19
| you may find current contact information at www.novell.com
21
| Author: Mike Lasky (mlasky@novell.com)
22
|***************************************************************************/
24
namespace Novell.iFolderWeb.Admin
29
using System.Resources;
31
using System.Web.UI.WebControls;
32
using System.Web.UI.HtmlControls;
35
/// Summary description for iFolderSearch.
37
public class iFolderSearch : System.Web.UI.UserControl
44
private ResourceManager rm;
47
/// Search operations.
49
protected DropDownList SearchOpList;
52
/// Search button control.
54
protected Button SearchButton;
59
protected HtmlInputText SearchNameTextBox;
65
protected Label NameLabel;
69
/// Event that notifies consumer that the search button has been clicked.
71
public event EventHandler Click = null;
78
/// Gets the search name value.
80
public string SearchName
82
get { return SearchNameTextBox.Value; }
86
/// Gets the search enumeration operation from the web selection.
88
public SearchOperation SearchOperation
92
SearchOperation searchOp = SearchOperation.BeginsWith;
93
string attribute = SearchOpList.SelectedValue;
95
if ( attribute == GetString( "BEGINSWITH" ) )
97
searchOp = SearchOperation.BeginsWith;
99
else if ( attribute == GetString( "ENDSWITH" ) )
101
searchOp = SearchOperation.EndsWith;
103
else if ( attribute == GetString( "CONTAINS" ) )
105
searchOp = SearchOperation.Contains;
109
searchOp = SearchOperation.Equals;
118
#region Private Methods
123
/// <param name="sender"></param>
124
/// <param name="e"></param>
125
private void Page_Load(object sender, System.EventArgs e)
128
rm = Application[ "RM" ] as ResourceManager;
132
// Initialize the localized fields.
133
SearchButton.Text = GetString( "SEARCH" );
134
NameLabel.Text = GetString( "NAME" );
136
SearchOpList.Items[ 0 ].Text = GetString( "BEGINSWITH" );
137
SearchOpList.Items[ 1 ].Text = GetString( "ENDSWITH" );
138
SearchOpList.Items[ 2 ].Text = GetString( "CONTAINS" );
139
SearchOpList.Items[ 3 ].Text = GetString( "EQUALS" );
140
SearchOpList.SelectedValue = GetString( "BEGINSWITH" );
142
// Set focus to the inbox control.
143
SetFocus( SearchNameTextBox );
145
// Set the javascript function that will handle key presses.
146
SearchNameTextBox.Attributes[ "OnKeyPress" ] = "return SubmitKeyDown(event, '" + SearchButton.ClientID + "');";
151
/// Sets focus to the specified control.
153
/// <param name="ctrl"></param>
154
private void SetFocus( System.Web.UI.Control ctrl )
156
string s = "<SCRIPT language='javascript'>document.getElementById('" + ctrl.ClientID + "').focus() </SCRIPT>";
157
Page.RegisterStartupScript( "focus", s );
162
#region Protected Methods
165
/// Default action for enter key.
167
/// <returns></returns>
168
protected string GetKeyDown()
170
return "SubmitKeyDown(event, " + SearchButton.ClientID + ")";
174
/// Get a Localized String
176
/// <param name="key">Key to the localized string.</param>
177
/// <returns>Localized string.</returns>
178
protected string GetString( string key )
180
return rm.GetString( key );
184
/// Event handler that gets called when the search button is clicked.
186
/// <param name="source"></param>
187
/// <param name="e"></param>
188
protected void OnSearchButton_Click( object source, EventArgs e )
198
#region Public Methods
201
#region Web Form Designer generated code
206
/// <param name="e"></param>
207
override protected void OnInit(EventArgs e)
210
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
212
InitializeComponent();
217
/// Required method for Designer support - do not modify
218
/// the contents of this method with the code editor.
220
private void InitializeComponent()
222
SearchButton.Click += new EventHandler( OnSearchButton_Click );
223
this.Load += new System.EventHandler(this.Page_Load);