jQuery to change listbox selection mode - asp.net

I have an ASP.NET page with a listbox whose selection mode is set to multiple by default. I would like to set its selection mode to single on a button click.
Code snippet of my attempt:
$('#testBtn').click(function(){
$('#testListBox').attr("SelectionMode","Single");
});
It is not working though. What am I doing wrong here and how to get it to work?
cheers

The select box uses the attribute "multiple" to determine if it should allow multiple selections. You can remove it via jQuery using the removeAttr() function:
$('#testListBox').removeAttr('multiple');

Related

Devexpress Gridcontrol Multiselect without using indicator column

Is there any way to allow the user to do a multiple row selection just by clicking and dragging along cells within the actual grid? I.e. Without using the indicator column?
You can do that by cell using just properties by setting the following properties located in Gridview.Options
Multiselect = True
MultiSelectMode = CellSelect
UseIndicatorForSelection = False
If you need to do it by entire rows, you are stuck writing that functionality yourself using GridView.CalcHitInfo and various events.
To achieve this behavior, you need to handle the MouseDown and
MouseMove events and select rows programmatically. You also need to
enable the multi-selection feature and switch the multi-selection
mode to "CellSelect" to be able to select individual cells.
download the attached sample from this link and customize it to implement your functionality...
MultiSelect Rows & Cells simultaneously
check the following thread, which using indicator but you can customize it hiding indicator and setting select option to cellselect etc...
"mulitiselect without CTRL key" on Devexpress..
search result that help you implement that you are looking for...

asp.net ListBox deselect item

I'm usting an asp:ListBox and I understand that to deselect items the user needs to hold down control while clicking on a selected item. Is there a way to make it that clicking on a selected item will deselect it without holding down control?
You can, but not in ASP.Net. You need to change the client-side HTML, meaning you need to code it using Javascript, to change the default behaviour or a select box. Something like:
<script>
function MyHandle(oSelect)
{
(change behaviuor here, using object oSelect)
return false;
}
</script>
<SELECT onclick="MyHandle(this)">
...
</SELECT>
But... I really recomend against it. To acheive what you want, your "MyHandle" function would have to emulate everything that normal forms does: selecting, de-selecting, range selecting (using shift), single selection without affecting others (control key), etc.
Its easier to switch to checkboxes, as Jakob suggested.
I don't think asp.net's listbox can do that out of the box (I think winform's listbox can) but you can set SelectionMode to Multiple and write javascript to achieve the behavior you require.

Detecting out-of-view flex controls

In my flex app I have custom tooltips on buttons that hide and show based on user context.
The problem that I dealing with is that when I call my showTips() function I only want to show tooltips on the buttons that visible in the view. So buttons that on a un-selected tab (tabNavigator) should not show the tooltips.
For some reason all tooltips are showing.
Is there a way to detect if a button is not in current view, like on a un-selected tab?
If you gave us some code I could check this out, but would this work?
if(button.parent.visible) { showTip(button);}
Instead of custom coding for each button, make use your tabnavigator's creation policy is set to "auto".
Check this link for more details
http://livedocs.adobe.com/flex/3/html/help.html?content=layoutperformance_05.html

Is it possible to catch a comboBoxes value before change with a change event

I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.
So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?
Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.
Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?
update:
If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.
Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.
HTH

ASP.NET AjaxControlToolKit Accordion set active pane via javascript

I would like to be able to change the active pane of an accordion using javascript.
I see a behavior set_SelectedIndex but I can not seem to get it to work.
How can I find out what the supported methods are for this control?
How can I set the selected index from the page?
I found a comment on this blogpost http://disturbedbuddha.wordpress.com/2007/11/30/selecting-an-ajax-accordionpane-by-id/ which showed me how to use Accordion.AccordionBehavior.set_SelectedIndex(index);.
I am outputting a startup script from the codebehind of variables with the paneIds prefaces with a code and their index. This allows me to set the active pane by id.

Resources