private void ShowErrorMessage() { //Clear out the fact that the user did a search before this. Keyword = ""; OldKeywords.Clear(); lblResultsForKeyword.Text = ""; lblTopResultsXofYKeyword.Text = ""; lblSearchWithinResultKeyword.Text = ""; phError.Visible = true; ShowResultsXoYLabels(0, 0, 0); //For paging change. PreviousItemsPerPage = ItemsPerPage; //Set the Search Within Results Radio button to new search rblSWRSearchType.SelectedIndex = 0; spPager.RecordCount = 0; //// Web Analytics ************************************************* // Add number of search results to analytics this.PageInstruction.SetWebAnalytics(WebAnalyticsOptions.eVars.evar10, wbField => { wbField.Value = "0"; }); //// End Web Analytics ********************************************* }
private void DoSearchWithinResults() { if (Strings.Clean(txtSWRKeyword.Text) == null) { ShowErrorMessage(); } else { if (rblSWRSearchType.SelectedValue == "2") //Search Within Results { //Add the last keyword to the old keywords if (!String.IsNullOrEmpty(Keyword)) { OldKeywords.Add(Keyword); } //Set the current keyword Keyword = Strings.Clean(txtSWRKeyword.Text); LogUserInput("Refine-Keyword:" + ( OldKeywordsForQuery.Length > 0 ? OldKeywordsForQuery + "|" + Keyword : Keyword)); } else //New Search { //Log new search OldKeywords.Clear(); Keyword = Strings.Clean(txtSWRKeyword.Text); LogUserInput("New-Keyword:" + Keyword); } this.CurrentPage = 1; txtSWRKeyword.Text = ""; //Clear the text box. .NET will leave in the text, which is what google does, but not what cancer.gov has done. LoadResults(); } }
/// <summary> /// Event method sets content version and template and user control properties<br /><br /> /// [1] Input form parameters:<br /> /// keyword {string: search string},<br /> /// first {integer: ordinal index of first result},<br /> /// resultSearch {string: search within results search string},<br /> /// chkCategories {comma-delimited set of strings: specific virtual paths to search},<br /> /// selectedPage {integer: current result page number}<br /> /// [2] Builds Verity and BestBet query language and Verity query xml document<br /> /// [3] Parses Verity results and errors<br /> /// [4] Builds Verity and BestBet result HTML<br /> /// [5] Builds paging control for results browsing<br /> /// </summary> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Setup the title, header, and left nav SetupCancerGovPageStuff(); SetLabels(); //Hide the error message phError.Visible = false; //set up the search collection (CancerGovEnglish or CancerGovSpanish) //determine what text needs to be removed from the title e.g. - National Cancer Institute SiteWideSearchConfig searchConfig = ModuleObjectFactory <SiteWideSearchConfig> .GetModuleObject(SnippetInfo.Data); if (searchConfig != null) { SearchCollection = searchConfig.SearchCollection; } if (Page.Request.RequestType == "POST") { if (!IsPostBack) { /*********************************************/ /* Search using header search box */ /*********************************************/ Keyword = Request.Params["swKeyword"]; if (Keyword == string.Empty) { ShowErrorMessage(); } else { LoadResults(); //Log User Input for initial search. LogUserInput("Keyword:" + Keyword); } } else { //This is a postback from a user changing the items per page or //searching within results. There is one problem though. //By default, if (Strings.Clean(Request.Params["__EVENTTARGET"]) == null && Strings.Clean(Request.Params["__EVENTARGUMENT"]) == null && Strings.Clean(Request.Params[btnTextChangePageUnit.UniqueID]) == null && Strings.Clean(Request.Params[btnSWRTxtSearch.UniqueID]) == null) { //THIS IS FOR IE with no JS. Oddly in most ways it is more broken than firefox, but //is so broken that we can easily tell that the user hit enter on the only //text box. //Basically if all the buttons that can be clicked are null, and there //is no event target or argument, then this is IE with Javascript turned //off and the user clicked enter on the text box. Also, image buttons do //not come back ID, but ID.x and ID.y. (Hopefully screen readers send those //things too. // //We need to handle this stuff after all the other postback events happen. //so lets just set a variable for now. _isIENoJSAndHitEnderInTheSearchBox = true; } } } else { /*********************************************/ /* Either Paging or a DYM Click */ /*********************************************/ //No Matter if this is a DYM or a Paging, swKeyword is the keyword. (There may be an old one, but that is for later) Keyword = Request.Params["swKeyword"]; if (Keyword == string.Empty) { ShowErrorMessage(); } else { //These things only apply to paging //Get Items per page. ItemsPerPage = Strings.ToInt(Request.Params["pageunit"], 10); //Get the current Page CurrentPage = Strings.ToInt(Request.Params["page"], 1); //"De-serialize" old keywords. if (!string.IsNullOrEmpty(Request.Params["old_keywords"])) { string[] oldKeys = Request.Params["old_keywords"].Split(new char[] { '|' }); OldKeywords.AddRange(oldKeys); } LoadResults(); } } // build the OnClineClick value for results search var siteResultSearchSubmitParameter = ""; if (PageDisplayInformation.Language == DisplayLanguage.Spanish) { siteResultSearchSubmitParameter = "true"; } // removed search validation for now var siteResultSearchSubmitCall = ""; //"return siteResultSearchSubmit(" + siteResultSearchSubmitParameter + ")"; // Web Analytics ************************************************* if (WebAnalyticsOptions.IsEnabled) { siteResultSearchSubmitCall += "return NCIAnalytics.SiteWideSearchResultsSearch(this,'" + txtSWRKeyword.ClientID + "','" + rblSWRSearchType.UniqueID + "')"; } // End Web Analytics ********************************************* if (!String.IsNullOrEmpty(siteResultSearchSubmitCall)) { siteResultSearchSubmitCall += ";"; btnSWRTxtSearch.OnClientClick = siteResultSearchSubmitCall; } }