Maybe you can create a delegate and an event to pass a list of searchvalues? This way you can easily add another or multiple display controls in case that ever becomes necessary.
Note that this is just some quick sample code that should be optimized/improved.
public class SearchControl
{
public delegate void SearchEventHandler(object sender, Dictionary<string, string> SearchValues);
public event SearchEventHandler OnSearch;
public SearchControl()
{
btnSearch.Click += new EventHandler(Search);
}
protected void Search(object sender, EventArgs e)
{
if (OnSearch != null)
{
Dictionary<string, string> searchValues = new Dictionary<string, string>();
searchValues.Add("name", "John");
searchValues.Add("age", "24");
OnSearch(this, searchValues);
}
}
}
public class DisplayControl
{
public void ShowResults(Dictionary<string, string> SearchValues)
{
// Some logic here...
}
}
public class YourWebPage
{
SearchControl searcher = new SearchControl();
DisplayControl displayer = new DisplayControl();
public YourWebPage()
{
searcher.OnSearch += new SearchControl.SearchEventHandler(searcher_OnSearch);
}
public void searcher_OnSearch(object sender, Dictionary<string, string> SearchValues)
{
displayer.ShowResults(SearchValues);
}
}