Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Max number of selections from a listbox/other control reset

Max number of selections from a listbox/other control reset

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptdatabasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mjc225
    wrote on last edited by
    #1

    Greetings. I am trying to build a form with one listbox and one drop-down list. For the listbox, I'd like the user to only be able to select 3 items. Is there any way to limit that? I'd also like the other control to be blanked out once the user selects something from the other control. I am able to do this for the listbox with onSelectedIndexChanged since only one selection is made, but if I do this for the Listbox it seems to trigger a postback each time. I was hoping for just the equivalent of OnFocus. Is this possible in .NET or would I have to use JavaScript? And does anyone have any good code snippets for either of these? Thanks in advance.

    A 1 Reply Last reply
    0
    • M mjc225

      Greetings. I am trying to build a form with one listbox and one drop-down list. For the listbox, I'd like the user to only be able to select 3 items. Is there any way to limit that? I'd also like the other control to be blanked out once the user selects something from the other control. I am able to do this for the listbox with onSelectedIndexChanged since only one selection is made, but if I do this for the Listbox it seems to trigger a postback each time. I was hoping for just the equivalent of OnFocus. Is this possible in .NET or would I have to use JavaScript? And does anyone have any good code snippets for either of these? Thanks in advance.

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      mjc225 wrote:

      I am able to do this for the listbox with onSelectedIndexChanged since only one selection is made, but if I do this for the Listbox it seems to trigger a postback each time.

      Change the ListBox SelectionMode = Multiple , Put the ListBox inside Update Panel, Use One Counter- Maintain the Counter Value in ViewState ,Now onSelectionIndexChaged, Increase the count and Update the ViewState , Check the value on every partial post back, If its greater than three show message. :) Hope this will help you !

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net View My Recent Article

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups