Using system;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. componentmodel;
Namespace searchcontrol
{
/// <Summary>
/// Summary of search.
/// </Summary>
Public Class search: system. Web. UI. Control, inamingcontainer
{
Private system. Web. UI. webcontrols. textbox txtcondition;
Private system. Web. UI. webcontrols. dropdownlist ddlcontent;
Private system. Web. UI. webcontrols. Button btnsearch;
Public Event System. eventhandler tosearch;
Public Search ()
{
This. ensurechildcontrols ();
This. btnsearch. Click + = new eventhandler (btnsearch_click );
}
Public String text
{
Get {return this.txt condition. Text ;}
Setincluthis.txt condition. Text = value ;}
}
Public object datasource
{
Get {return this. ddlcontent. datasource ;}
Set {ddlcontent. datasource = value ;}
}
Public String datatextfield
{
Get {return this. ddlcontent. datatextfield ;}
Set {This. ddlcontent. datatextfield = value ;}
}
Public String datavaluefield
{
Get {return this. ddlcontent. datavaluefield ;}
Set {This. ddlcontent. datavaluefield = value ;}
}
Public String selectvalue
{
Get {return this. ddlcontent. selectedvalue ;}
Set {This. ddlcontent. selectedvalue = value ;}
}
Public String selecttext
{
Get {return this. ddlcontent. selecteditem. Text ;}
}
Public void databind ()
{
This. ddlcontent. databind ();
}
// Public listitemcollection items
//{
// Get {return this. ddlcontent. items ;}
//}
Public String buttontext
{
Get {return this. btnsearch. Text ;}
Set {This. btnsearch. Text = value ;}
}
Protected override void createchildcontrols ()
{
Txtcondition = new Textbox ();
This. ddlcontent = new dropdownlist ();
This. btnsearch = new button ();
This. btnsearch. Text = "query ";
System. Web. UI. webcontrols. Literal [] lt = new literal [2];
For (INT I = 0; I <lt. length; I ++)
{
Lt [I] = new literal ();
Lt [I]. Text = "& nbsp ;";
}
This. Controls. Add (txtcondition );
This. Controls. Add (LT [0]);
This. Controls. Add (this. ddlcontent );
This. Controls. Add (LT [1]);
This. Controls. Add (this. btnsearch );
}
Private void btnsearch_click (Object sender, eventargs E)
{
If (tosearch! = NULL)
{
Tosearch (this, e );
}
}
}
}
The main function is to enter the query content in the text box. In the drop-down box, you can select a query range, for example, category, time =. click the button to start the query,
The widget looks as follows: