private void BindDataToControls(SearchProperties searchresult) { txtFileName.Text = Path.GetFileName(searchresult.filesList[searchresult.currentFileIndex]); lblResultCount.Text = String.Format("File {0} of {1}", searchresult.currentFileIndex + 1, searchresult.numberOfFiles); txtFileContent.Text = File.ReadAllText(searchresult.filesList[searchresult.currentFileIndex]); SetNavigationButtons(searchresult); }
protected void Page_Load(object sender, EventArgs e) { if (ViewState["searchresult"] != null) { searchresult = (SearchProperties)ViewState["searchresult"]; } }
private SearchProperties SaveResult(ArrayList filesList) { string[] filesArray = (string[])filesList.ToArray(typeof(string)); SearchProperties search = new SearchProperties(filesArray, filesList.Count); ViewState["searchresult"] = search; return(search); }
protected void Page_PreRender(object sender, EventArgs e) { if (IsPostBack && ViewState["searchresult"] != null) { searchresult = (SearchProperties)ViewState["searchresult"]; BindDataToControls(searchresult); SetResultsViewingArea(true); } }
protected void btnSearch_Click(object sender, EventArgs e) { SearchFiles search = new SearchFiles(txtSearchTerm.Text); ArrayList filesList = search.PerformSearch(); if (filesList.Count > 0) { SearchProperties searchresult = SaveResult(filesList); SetResultsViewingArea(true); BindDataToControls(searchresult); } else { ViewState["searchresult"] = null; SetResultsViewingArea(false); } }
private void SetNavigationButtons(SearchProperties searchresult) { // First (of all files) button if (searchresult.currentFileIndex == 0 || searchresult.numberOfFiles == 0) { btnFirst.Enabled = false; } else { btnFirst.Enabled = true; } // Previous button if (searchresult.currentFileIndex == 0 || searchresult.numberOfFiles == 0) { btnPrevious.Enabled = false; } else { btnPrevious.Enabled = true; } // Next button if (searchresult.currentFileIndex < searchresult.lastFileIndex) { btnNext.Enabled = true; } else { btnNext.Enabled = false; } // Last (of all files) button if (searchresult.currentFileIndex == searchresult.lastFileIndex) { btnLast.Enabled = false; } else { btnLast.Enabled = true; } }