Creating a Simple Combo Box in a Web App


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Creating a Simple Combo Box in a Web App

Hybrid View

  1. #1
    Join Date
    Jun 2004
    Posts
    50

    Creating a Simple Combo Box in a Web App

    Hey guys!

    I'm trying to create a simple combo box for my web application. I know this can be done in a windows app by changing the dropdownstyle to "simple." In a web app, i'm not given this property.

    I want the user to be able to copy and paste into my textbox a part number, which will then automatically find that part in the listbox below, which is full of say...1000 diff part numbers. Otherwise the user has to remember the number and navigate with the scroll bar to that part number (just a listbox w/ no textbox). Is their any way to create a simple combo box in a web app?

    If not, then can i just create a textbox, and a listbox below it and create code to have the two interact? If so, i'm having trouble trying to distinguish in the code when the user has completed typing into the textbox, so i can begin my file search in the listbox w/ that part number the user has written (in the txtbox). Is their like an infocus method i could use for the textbox, telling me when someone is writing into the textbox? Thanks in advance guys and gals!

    -Rancho

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jun 2004
    Posts
    50
    Phil or anyone,

    Is their any way to modify a simple routine such as this?

    Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    'Retrieve the item's listindex

    Dim i As Integer = ListBox1.FindString(TextBox1.Text)

    'highligting the matched ones

    ListBox1.SelectedIndex = i

    End Sub
    ------
    Seems to me like the textchanged event doesnt trigger everytime a new character is typed into the textbox. The above is for a windows form, which i get working, but "findstring()" isn't allowed in a web form. Seems like the textchanged event only triggers when you are done typing and hit "enter." If i could get this event to trigger everytime a new character is typed then i could easily highlight the correct item in the listbox once the textbox.text = a item in the list box.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    ASP.NET code-behind runs on the server. If you want to perform an action each time the text changes, it's better to do it in the user's browser, using JavaScript. Another option is to use XMLHttp to run server code without refreshing the page (like Google Suggest: http://www.google.com/webhp?complete=1 ). For more information on this technique, see http://serversideguy.blogspot.com/20...dissected.html
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center