How to restrict uncheck option from radlistbox

4 posts, 0 answers
  1. suresh
    suresh avatar
    30 posts
    Member since:
    Apr 2011

    Posted 19 Feb 2012 Link to this post

    Hi there,
     I'm using RadListBox with checkboxes=true..By default I have loading the items and some of the items have checked..I need to restrict  uncheck option for checked items.How can i achieve this?.


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 21 Feb 2012 Link to this post


    One suggestion is to try setting the checked items as disabled on OnClientLoad event.
    function OnClientLoad(sender, args)
       for (i = 0; i < sender.get_checkedItems().length; i++)

  3. suresh
    suresh avatar
    30 posts
    Member since:
    Apr 2011

    Posted 21 Feb 2012 Link to this post

    Thanks princy..I don't need to disable an item.Because I have to do something in OnselectedIndexChanged of an item..By default all items are checked..I need to restrict uncheck option for that checkboxes(i.e readonly or something else..)..

  4. Richard
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 22 Feb 2012 Link to this post


    Have you tried attaching a JavaScript function to the RadListBox's OnClientItemChecking event?

    Since the checked state returned by the item's get_checked() function is not yet changed to reflect the new value, you can cancel the attempt to toggle it.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <head runat="server">
        <telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <%--Needed for JavaScript IntelliSense in VS2010--%>
                <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        <script type="text/javascript">
            function OnClientItemCheckingHandler(sender, eventArgs) {
                var item = eventArgs.get_item();
                var message = "You are not allowed to ";
                message += item.get_checked() ? "uncheck" : "check";
                message += " the item " + item.get_text();
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <div class="title">
                Checkboxes only:</div>
            <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
                <div class="list-panel">
                    <telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" Width="200px"
                        Height="300px" OnClientItemChecking="OnClientItemCheckingHandler">                  
                            <telerik:RadListBoxItem Text="Arts" />
                            <telerik:RadListBoxItem Text="Biographies" Checked="true" />
                            <telerik:RadListBoxItem Text="Children's Books" />
                            <telerik:RadListBoxItem Text="Computers � Internet"/>
                            <telerik:RadListBoxItem Text="Cooking" Checked="true" />
                            <telerik:RadListBoxItem Text="History" />
                            <telerik:RadListBoxItem Text="Fiction" />
                            <telerik:RadListBoxItem Text="Mystery" Checked="true" />
                            <telerik:RadListBoxItem Text="Nonfiction" />
                            <telerik:RadListBoxItem Text="Romance" />
                            <telerik:RadListBoxItem Text="Science Fiction " />
                            <telerik:RadListBoxItem Text="Travel" />
                    <asp:Button ID="Button1" runat="server" Text="Get Checked Items!" CssClass="qsfButtonBigger"
                        OnClick="Button1_Click" />
                    <div class="module">
                        <strong>Checked Items:</strong>
                        <br />
                        <br />
                        <asp:Label ID="itemsClientSide" runat="server" BorderStyle="None" CssClass="text" />

    Hope this helps!
Back to Top