This is a migrated thread and some comments may be shown as answers.

Postback after selecting one of selectedItems in ListBox

12 Answers 451 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Claudio Falco
Top achievements
Rank 1
Claudio Falco asked on 16 Nov 2009, 05:06 PM
Hi
I have a RadListBox with some item selected. If I click on an item already selected, no event is fired server-side (selected index does not change but item do!!). How can I know what is the selected item?
Thanks for answering.

Claudio Falco

12 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 16 Nov 2009, 10:06 PM
Have you set the AutoPostBack property to true?
0
Claudio Falco
Top achievements
Rank 1
answered on 17 Nov 2009, 10:42 AM
Of course!!!! but it doesn't solve the problem
0
Mark Galbreath
Top achievements
Rank 2
answered on 17 Nov 2009, 11:55 AM
When I turned autopostback on, my pair of list boxes crashed and burned - stopped working after the first click.  Too bad the online documentation is so poor and the downloadable documentation is either out of date or non-existent.  Seems like whenever something doesn't work around here, I get sent to some sample project instead of straight answers.
0
Schlurk
Top achievements
Rank 2
answered on 17 Nov 2009, 06:19 PM
Claudio: Just to clarify are you using SelectionMode="Multiple" and selecting an item within the selected items? If this is the case I see the same behavior on my machine.

Mark: My downloaded documentation is the same as the one found online, which I've found very helpful. What does your code look like? Whenever something like that happens I usually just find a property or event I'm subscribing to that is the culprit.
0
Claudio Falco
Top achievements
Rank 1
answered on 17 Nov 2009, 08:39 PM
Yes Schlurk, this is my case! Solution??
0
Mark Galbreath
Top achievements
Rank 2
answered on 18 Nov 2009, 11:49 AM
My downloaded documentation (re-d/l yesterday) is dated Nov. 2008.  How is that supposed to cover Q3 2009?  As for the online docs, they are also out of date, are not logically organized by API, and are impossible to print.  For example, there is NO mention of RadListBox in the d/l documentation ("Rad Controls for ASP.NET Ajax"), only RadComboBox.  I have also found that much of the VB code does not work; apparently because the Telerik developers prefer C# and do not test their VB code.

That being said, I still cannot get a transfer from listbox A to listbox B with autopostbackduringtransfer = true.  Why isn't there two separate threads - client-side and server-side - in the documentation (that doesn't exist) on how to do what should be the most basic of functions?  And when I get transfers working with Ajax using 2x-click and drag-n-drop, the transfer button stops working.  And why don't I have more control over the transfer buttons?  If I want A -> B but not A <- B, why is the reverse arrow button still there?  And where is the sort button/icon?  I still can't figure that out.

Sheesh!  $800.00???
0
Casey
Top achievements
Rank 1
answered on 18 Nov 2009, 02:04 PM
Mark,

I'm not sure about the documentation issue, I found some helpful information by following the different subjects under the RadListBox section from the following link though:
http://www.telerik.com/help/aspnet-ajax/listboxoverview.html

Also, it looks like there is a way to hide the transfer from Right to Left button:
http://www.telerik.com/help/aspnet-ajax/listbox-hide-transfer-to-left-button.html

Hope this helps!
Casey
0
Mark Galbreath
Top achievements
Rank 2
answered on 18 Nov 2009, 02:41 PM
Thanks, Casey!  I was actually looking at that page when your response post appeared.  I can't help but think that if I was the developer of the RadListBox control, adding a visibility switch to any component would have been an obvious convenience.  Having to programmatically manipulate DOM objects is a PITA and avoiding same is the reason I paid for RadControls in the first place.
0
Casey
Top achievements
Rank 1
answered on 18 Nov 2009, 02:48 PM
Mark,

I definitely understand that this can be a pain. Hopefully Telerik will consider adding this functionality in the near future!

Casey
0
Schlurk
Top achievements
Rank 2
answered on 18 Nov 2009, 02:59 PM
To get the most recent documentation you should visit the online version, and as for printing just save the trees and keep it in your browser - it's easier to copy and paste that way :)

Here's are working implementations of what you're trying to achieve:

AutoPostBack:
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
     <style type="text/css"
        div.RadListBox .rlbTransferTo, 
        div.RadListBox .rlbTransferToDisabled, 
        div.RadListBox .rlbTransferAllToDisabled, 
        div.RadListBox .rlbTransferAllTo 
        { 
            display: none; 
        } 
     </style>  
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadListBox ID="RadListBox1" runat="server" AutoPostBack="true" AutoPostBackOnTransfer="true" 
         SelectionMode="Multiple" AllowTransfer="true" TransferMode="Move" TransferToID="RadListBox2" Height="120px" EmptyMessage="No Items" 
          EnableDragAndDrop="true" AllowTransferOnDoubleClick="true"
        <Items> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem3" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem4" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem5" /> 
        </Items> 
    </telerik:RadListBox> 
    <telerik:RadListBox ID="RadListBox2" runat="server" EmptyMessage="No Items" Height="120px" EnableDragAndDrop="true"
    </telerik:RadListBox> 
    </form> 
     
</body> 
</html> 


Ajax:
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
     <style type="text/css"
        div.RadListBox .rlbTransferTo, 
        div.RadListBox .rlbTransferToDisabled, 
        div.RadListBox .rlbTransferAllToDisabled, 
        div.RadListBox .rlbTransferAllTo 
        { 
            display: none; 
        } 
     </style>  
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadListBox1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadListBox1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="RadListBox2"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadListBox2" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadListBox ID="RadListBox1" runat="server" 
         SelectionMode="Multiple" AllowTransfer="true" TransferMode="Move" TransferToID="RadListBox2" Height="120px" EmptyMessage="No Items" 
          EnableDragAndDrop="true" AllowTransferOnDoubleClick="true"
        <Items> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem3" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem4" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem5" /> 
        </Items> 
    </telerik:RadListBox> 
    <telerik:RadListBox ID="RadListBox2" runat="server" EmptyMessage="No Items" Height="120px"
    </telerik:RadListBox> 
    </form> 
     
</body> 
</html> 

It seems like you are running into an issue with implementing both the AutoPosback feature, as well as Ajaxifying the control. Essentially you are telling the controls to specifically do a full postback while your AjaxManager is trying to only do a partial one - hence the issues.

Usually the client-side examples are found under the Client-side Programming sections of each control, and there are also some client-side and server-side equivalent examples under the "How-to" sections. I always find them helpful when looking into what my best alternative (client or server-side) might be. As you can imagine there are certain things that you can only do through client-side, and somethings best left for server-side, so it might be difficult to show exact examples from both perspectives.
0
Mark Galbreath
Top achievements
Rank 2
answered on 18 Nov 2009, 03:57 PM
Very cool, Schlurk!  I probably wouldn't be so pi33ed off if I had 2 monitors and could have the online docs up on one all the time.  :-)
0
Schlurk
Top achievements
Rank 2
answered on 18 Nov 2009, 05:29 PM
You are quite welcome! I should see if I can get a second monitor to have the docs up all the time as well ;) I tend to have a tabs with each product documentation in a browser window that I just cycle through, but it would be nice to just look over to the side instead :D
Tags
ListBox
Asked by
Claudio Falco
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Claudio Falco
Top achievements
Rank 1
Mark Galbreath
Top achievements
Rank 2
Casey
Top achievements
Rank 1
Share this question
or