Control SearchControl(SearchControlTypes controlType) { var moduleId = _parent.ModuleId; switch (controlType) { case SearchControlTypes.Columns: var drpSearchableColumns = (DropDownList) (_searchPlaceHolder.FindControl("drpSearchableColumns")); if (drpSearchableColumns == null) { var drp = new DropDownList {ID = "drpSearchableColumns", CssClass = "NormalTextBox"}; _searchPlaceHolder.Controls.Add(drp); var lbl = new Label {ID = "lblSearchableColumn"}; lbl.Font.Bold = true; lbl.Visible = false; _searchPlaceHolder.Controls.Add(lbl); LoadColumns(); drpSearchableColumns = drp; if (! string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}c", moduleId)])) { drpSearchableColumns.SelectedValue = _parent.Request.QueryString[string.Format("u{0}c", moduleId)].UrlHexDecode(); } } return drpSearchableColumns; case SearchControlTypes.Operator: var drpSearchMode = (DropDownList) (_searchPlaceHolder.FindControl("drpSearchMode")); if (drpSearchMode == null) { var drp = new DropDownList {ID = "drpSearchMode", CssClass = "NormalTextBox"}; drp.Items.Add( new ListItem(Localization.GetString("SearchMode.Contain", _parent.LocalResourceFile), "contain")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.StartWith", _parent.LocalResourceFile), "startwith")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.EndWith", _parent.LocalResourceFile), "endwith")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.Equal", _parent.LocalResourceFile), "equal")); _searchPlaceHolder.Controls.Add(drp); drpSearchMode = drp; if (! string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}m", moduleId)])) { drpSearchMode.SelectedValue = _parent.Request.QueryString[string.Format("u{0}m", moduleId)]; } } return drpSearchMode; case SearchControlTypes.Search: var txtSearch = (TextBox) (_searchPlaceHolder.FindControl("txtSearch")); if (txtSearch == null) { txtSearch = new TextBox {ID = "txtSearch"}; _searchPlaceHolder.Controls.Add(txtSearch); if (! string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}q", moduleId)])) { txtSearch.Text = _parent.Request.QueryString[string.Format("u{0}q", moduleId)].UrlHexDecode(); } } return txtSearch; } return null; }
Control SearchControl(SearchControlTypes controlType) { var moduleId = _parent.ModuleId; switch (controlType) { case SearchControlTypes.Columns: var drpSearchableColumns = (DropDownList)(_searchPlaceHolder.FindControl("drpSearchableColumns")); if (drpSearchableColumns == null) { var drp = new DropDownList { ID = "drpSearchableColumns", CssClass = "NormalTextBox" }; _searchPlaceHolder.Controls.Add(drp); var lbl = new Label { ID = "lblSearchableColumn" }; lbl.Font.Bold = true; lbl.Visible = false; _searchPlaceHolder.Controls.Add(lbl); LoadColumns(); drpSearchableColumns = drp; if (!string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}c", moduleId)])) { drpSearchableColumns.SelectedValue = _parent.Request.QueryString[string.Format("u{0}c", moduleId)].UrlHexDecode(); } } return(drpSearchableColumns); case SearchControlTypes.Operator: var drpSearchMode = (DropDownList)(_searchPlaceHolder.FindControl("drpSearchMode")); if (drpSearchMode == null) { var drp = new DropDownList { ID = "drpSearchMode", CssClass = "NormalTextBox" }; drp.Items.Add( new ListItem(Localization.GetString("SearchMode.Contain", _parent.LocalResourceFile), "contain")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.StartWith", _parent.LocalResourceFile), "startwith")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.EndWith", _parent.LocalResourceFile), "endwith")); drp.Items.Add( new ListItem(Localization.GetString("SearchMode.Equal", _parent.LocalResourceFile), "equal")); _searchPlaceHolder.Controls.Add(drp); drpSearchMode = drp; if (!string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}m", moduleId)])) { drpSearchMode.SelectedValue = _parent.Request.QueryString[string.Format("u{0}m", moduleId)]; } } return(drpSearchMode); case SearchControlTypes.Search: var txtSearch = (TextBox)(_searchPlaceHolder.FindControl("txtSearch")); if (txtSearch == null) { txtSearch = new TextBox { ID = "txtSearch" }; _searchPlaceHolder.Controls.Add(txtSearch); if (!string.IsNullOrEmpty(_parent.Request.QueryString[string.Format("u{0}q", moduleId)])) { txtSearch.Text = _parent.Request.QueryString[string.Format("u{0}q", moduleId)].UrlHexDecode(); } } return(txtSearch); } return(null); }