An Asp.net control that implements the query function

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.