Search code examples
asp.netkendo-uitelerikc#-3.0

Make the <telerik:RadDropDownList> as ReadOnly


I am trying to make/set the telerik controls to read only, so no one will be able to edit the values.

I have searched and tried different solutions but none of them seems to work for me.

I have tried making the following solution, the telerik drop down list ui code is:

<telerik:RadDropDownList ID="rddPrefix" runat="server" width="100%" DropDownHeight="200"> </telerik:RadDropDownList>

and applying the javascript below:

<script type="text/javascript">
   var dropdownlist = $("#rddPrefix");
   dropdownlist.readonly();
</script>

Please provide some appropriate solution. Thanks in advance.


Solution

  • You can use the following approach to achieve this requirement:

    <telerik:RadDropDownList ... OnClientDropDownOpening="preventComboAction"
        OnClientItemSelecting="preventComboAction">
    
    <script>
    function preventComboAction(sender, args) {
        args.set_cancel(true);
    }
    </script>