You have a couple of options.
Option 1 - Bubble up the search clicked event in the user control to the parent page to consume the action
Handle the search button clicked event, or on command event.
Declare a button clicked event in the user control, and handle that even in the parent page.
Also declare a property in the user control to get,set the search value in the user controls textbox.
Then access this property from the parent page when it receives the clicked event.
User control:
public partial class MyUserControl
{
public String SearchCriteria
{
get{ return searchTextBox.Text; }
}
public event EventHandler SearchClicked;
protected void searchButton_Clicked(object sender, EventArgs e)
{
if(SearchClicked!=null)
{
SearchClicked(sender,e);
}
}
}
Parent page:
Lets assume MyUserControl exists on parent page as 'myUserControl'.
protected void Page_Load(object sender, EventArgs e)
{
myUserControl.SearchClicked += new EventHandler(myUserControl_SearchClicked);
}
protected void myUserControl_SearchClicked(object sender, EventArgs e)
{
}
Option 2 - Do all the search functionality inside the user control
public partial class MyUserControl
{
public DataTable SearchResult
{
get
{
if(Session["searchResult"] == null)
{
Session["searchResult"] = new DataTable;
}
return Session["searchResult"];
}
set
{ Session["searchResult"] = value; }
}
public event EventHandler SearchClicked;
protected void searchButton_Clicked(object sender, EventArgs e)
{
if(SearchClicked!=null)
{
SearchClicked(sender,e);
}
}
}