Max number of selections from a listbox/other control reset
-
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.
-
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.
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 theListBox inside Update Panel
, UseOne Counter- Maintain the Counter Value in ViewState
,NowonSelectionIndexChaged
, 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