A server custom control for Automatic completion

Source: Internet
Author: User
After several days of hard work, I finally completed the automatic compilation of controls, so I can't wait to share it with you.

Widget

The principle of this control is as follows: Use the listitemcollection set to save the list items and display Code As follows: < Input Name = "Txtbclass" Type = "Text" ID = "Txtbclass" Rows = "8" Matchanywhere = "True" Listallitemonfocus = "True" Style = "Width: 120px ;"   />
<? XML: namespace prefix = "FSC"/>









When the control obtains the focus, it defines a timer that filters the input characters in real time and adds them to a floating layer for selection. You can also use the cursor key to move the selection and press enter to confirm the selection. After the control is selected, the client events of the control are activated.OnchangedIn onchanged, you can perform the next step, for example, filling the second-level classification with Ajax. IfAutopostbackTo activate server events.Onchanged.

 

 

< Script >
Document. getelementbyid ( " Txtbclass " ). Onchanged =   Function ()
{
VaR Txtbclass = Document. getelementbyid ( " Txtbclass " ); // Category 1
VaR Txtsclass = Document. getelementbyid ( " Txtsclass " ); // Category 2
Txtsclass. Items. Clear ();
Txtsclass. Value =   "" ;
If (Txtbclass. selecteditem ! =   Null )
{
// Shop. webmanage. Product. getsclasslist use Ajax. Net to return the second-level list
VaR TB = Shop. webmanage. Product. getsclasslist (txtbclass. selecteditem. Value). value. Tables [ 0 ];
For ( VaR I =   0 ; I < TB. Rows. length; I ++ )
{
Txtsclass. Items. Add (Tb. Rows [I]. Text, TB. Rows [I]. value );
}
Txtsclass. savestate (); // Save to server list
}
}
</ Script >

Control client PropertiesSelecteditemReturns the selected item. The server correspondsSelecteditemAttribute.
Other attributes:
Rows: Sets the number of items displayed in the list.
Sendkeytab: Sets whether to move the cursor to the next control while pressing the Enter key.
Listallitemonfocus: Whether to display the list for selection when the cursor is obtained. Otherwise, only the characters entered are filtered.
Matchanywhere: Whether to match any character. Otherwise, match from the left.

this control has been included in faibclass. webcontrols. dll. This control has also improved pagingpanel and calendarbox controls. You can contact me if you are interested.

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.