Use dropdownex.pdf

Source: Internet
Author: User

This chapter describes how to use dropdownex.pdf. In the past, a Textbox Control with dropdownlist was created, but it was a huge weekly charge. The scriptCodeA large pile of data, but also need to take into account the interaction with the background, otherwise only static dropdownlist can be performed. But with dropdownex.pdf, all the troubles can be solved.

Step 1: Create Ajax Control Toolkit website

In this example, a Textbox Control, N linkbutton controls, a dropdownextings component, and an updatepanel component are required. After dragging all components into the design interface, the Code is as follows:

<ASP:Updatepanel ID= "Updatepanel1" Runat= "Server"> contenttemplate > Asp : textbox id =" textbox1 " text =" select item" runat =" server "> Asp : textbox > Asp : panel cssclass =" containpanel " id =" Panel1 " runat =" server " height =" 50px " width =" 125px " Style= "Visibility: hidden"> <ASP:Linkbutton ID= "Linkbutton1" Cssclass= "Link" Runat= "Server" Onclick= "Onselect"> Option 1</ASP:Linkbutton> <BR /> <ASP:Linkbutton ID= "Linkbutton2" Cssclass= "Link" Runat= "Server" Onclick= "Onselect"> Option 2</ASP:Linkbutton> <BR /> <ASP:Linkbutton ID= "Linkbutton3" Cssclass= "Link" Runat= "Server" Onclick= "Onselect"> Option 3 Asp : linkbutton > Br /> Asp : linkbutton id =" linkbutton4 " cssclass =" Link " runat =" server " onclick =" onselect "> Option 4 Asp : linkbutton > </ASP:Panel> <Ajaxtoolkit:Dropdownex.pdf ID= "Dropdownextender1" Runat= "Server" Targetcontrolid= "Textbox1" Dropdowncontrolid= "Panel1"> </Ajaxtoolkit:Dropdownex.pdf> </Contenttemplate> <Triggers> <ASP:Asyncpostbacktrigger Controlid= "Linkbutton1" Eventname= "Click" /> Asp : asyncpostbacktrigger controlid =" linkbutton2 " eventname =" click " /> Asp : asyncpostbacktrigger controlid =" linkbutton3 " eventname =" click " /> <ASP:Asyncpostbacktrigger Controlid= "Linkbutton4" Eventname= "Click" /> </Triggers> Asp : updatepanel >

Note:The above code has several key points. First, all components should be placed inUpdatepanelOfContenttemplate.Textbox1The selected value is displayed. If you do not needTextbox1The selected value is displayed.UpdatepanelYou only need to put the display value control,Textbox1,Panel1AndDropdownex.pdfCan be placed inUpdatepanelOutside. Second,Panel1Make sure to add style = "visibility: hidden". Otherwise, before the ajax.net script library is fully loaded,Panel1Will be displayed, resulting in poor flashing effect.

The following is the CSS style code for your reference:

. Containpanel { Background:# Ffcc00; Font-size:12px; Padding:3px; Border:Solid 1px #666; Line-height:150%; } . Link { Color:#666; Font-size:12px; }

Step 2: Set dropdownex.pdf

The setting of dropdownextings is very simple. The Code is as follows:

< Ajaxtoolkit : Dropdownex.pdf ID= "Dropdownextender1" Runat= "Server" Targetcontrolid= "Textbox1" Dropdowncontrolid= "Panel1"> </Ajaxtoolkit:Dropdownex.pdf>

TargetcontrolidThe ID of the control that activates the drop-down menu.Textbox1.DropdowncontrolidIt refers to the Control ID of the drop-down menu carrier. Here isPanel1.

Step 3: write background code

You will find that the previous linkbutton will execute an onselect function after you click it. Now we go to the CS file to compile this function. The code is very simple, as shown below:

Protected VoidOnselect (ObjectSender,EventargsE) { Textbox1.text = ((Linkbutton) Sender). text; }

This function indicates that the selected value is displayed in textbox1.

OK, run, the effect is as follows:

In general, textbox1 is just an ordinary textbox.

When you click with the mouse, the drop-down menu appears.

After selection, the menu disappears and the selected value is displayed in textbox1.

End:

This chapter describes how to use dropdownex.pdf. With dropdownex.pdf, we can integrate dropdownlist into many controls, including Textbox, label, and panel. You can test it by yourself.

Related Article

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.