using System;
using CMS.Controls;
using CMS.GlobalHelper;
using CMS.SettingsProvider;
public partial class CMSModules_IntranetPortal_Controls_SimpleUsersFilterControl : CMSAbstractBaseFilterControl
{
#region "Public properties"
///
/// Gets or sets the button text.
///
public string ButtonText
{
get
{
if (string.IsNullOrEmpty(btnSelect.Text))
{
btnSelect.Text = ResHelper.GetString("general.search");
}
return btnSelect.Text;
}
set
{
btnSelect.Text = value;
}
}
#endregion
///
/// OnLoad override - check wheter filter is set.
///
protected override void OnLoad(EventArgs e)
{
// Set filter only if it is not filter request
if (Request.Form[btnSelect.UniqueID] == null)
{
// Try to get where condition
string wherePart = ValidationHelper.GetString(ViewState["FilterCondition"], string.Empty);
if (!string.IsNullOrEmpty(wherePart))
{
// Set where condition and raise OnFilter change event
WhereCondition = GenerateWhereCondition(wherePart);
// Raise event
RaiseOnFilterChanged();
}
}
btnSelect.Text = ButtonText;
base.OnLoad(e);
}
///
/// Select button handler.
///
/// Sender
/// EventArgs
protected void btnSelect_Click(object sender, EventArgs e)
{
// Set where condition
WhereCondition = GenerateWhereCondition(txtValue.Text);
// Save filter condition
ViewState["FilterCondition"] = txtValue.Text;
// Raise OnFilterChange event
RaiseOnFilterChanged();
}
///
/// Generates where condition.
///
/// Phrase to be searched
/// Where condition for given phrase.
protected static string GenerateWhereCondition(string searchPhrase)
{
searchPhrase = SqlHelperClass.GetSafeQueryString(searchPhrase, false);
string whereCondition = "(FullName LIKE N'%" + searchPhrase + "%')";
return whereCondition;
}
}