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

RadListBox - stopping an autopostback

1 Answer 152 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Uday
Top achievements
Rank 1
Uday asked on 16 Feb 2012, 02:31 PM
Hi,

I have a RadListbox in the below fashion

<telerik:RadListBox ID="chkTools" runat="server" CheckBoxes="True" AutoPostBack="True"
OnItemCheck="chkTools_ItemCheck" EnableEmbeddedSkins="False" OnClientItemChecked="onItemChecked" 
OnClientItemChecking="onItemChecking"></telerik:RadListBox>

If i want to stop the post happening based on a condition which even should I use OnClientItemChecked or OnClientItemChecking and how should it be?

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 17 Feb 2012, 10:26 AM
Hello Uday,

If you need to prevent the postback of the page (and thus preventing the onitemcheck event to fire) you will need to use the OnClientItemChecking event and the following client side function:
<script type="text/javascript">
        function onItemChecking(sender, args) {
            args.set_cancel(true);
        }
    </script>
    

Here is also the markup that I used:
<telerik:RadListBox ID="chkTools" runat="server" CheckBoxes="True" AutoPostBack="True"
            OnClientItemChecking="onItemChecking" onitemcheck="chkTools_ItemCheck">
        <Items>
            <telerik:RadListBoxItem Text="item1" Value="1" />
            <telerik:RadListBoxItem Text="item2" Value="2" />
            <telerik:RadListBoxItem Text="item3" Value="3" />
            <telerik:RadListBoxItem Text="item4" Value="4" />
            <telerik:RadListBoxItem Text="item5" Value="5" />
            <telerik:RadListBoxItem Text="item6" Value="6" />
            <telerik:RadListBoxItem Text="item7" Value="7" />
        </Items>
    </telerik:RadListBox>

All the best,
Kate
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ListBox
Asked by
Uday
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or