Simple implementation of the dropdownlist drop-down box editable Function

Source: Internet
Author: User
Bingway original works. for reprinting, please indicate the author and source.

In Web programming, the Editable drop-down list is always a problem, and the following third-party controls and JS controls the select control.CodeBut compatible with all browsers,

The drop-down box is closely integrated with the text box, but it is not so easy to implement. Recently, when I was working on a project, I thought of The dropdownlist editable control provides better implementation methods.

My method is to add layers and text boxes on the dropdownlist. Some people prefer to use pixels to locate the text box. This is not only difficult to locate, but may also lead to deviations in the running effect of the browser; It is relatively easy to control layer positioning. Code
1   < ASP: dropdownlist ID = "Dropdownlist1" Runat = "Server" Autopostback = "True"  
2 Onselectedindexchanged = "Dropdownlistpolicselectedindexchanged"
3 Width = "180px" Style = "Position: absolute ;" >
4 < ASP: listitem > Test 1 </ ASP: listitem >
5 < ASP: listitem > Test 2 </ ASP: listitem >
6 < ASP: listitem > Test 3 </ ASP: listitem >
7 </ ASP: dropdownlist >
8 < Div >
9 < IFRAME ID = "Divshims" SRC = "Javascript: false ;" Scrolling = "No"  
10 Frameborder = "0" Style = "Position: absolute; Height: 20px ;" Width = "158px" >
11 </ IFRAME >
12 < Input Type = "Text" ID = "Txtcname" Runat = "Server" Style = "Width: 158px; position: absolute ;"   />
13 </ Div >

The drop-down box is closely integrated with the text box.

Load the page and trigger the dropdownlist1_selectedindexchanged event. assign a value to the text box.  StringText=Dropdownlist1.selectedvalue. tostring ();//Dropdownlist1 selected value

txtcname. value = text; // assign txtcname a value to run the test. Change the value of the drop-down list. This is the simplest method I have come up with. If you have any friends in the garden, please kindly advise me.

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.