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

How to disable a numeric text box?

3 Answers 145 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Frank Michael
Top achievements
Rank 1
Frank Michael asked on 27 May 2010, 12:48 PM
        <%  var numericTextBox = Html.Telerik() 
                .NumericTextBox() 
                .Name(model.name) 
                .Value(model.value) 
                .MaxValue(10000) 
                .MinValue(0) 
                .Spinners(model.spinnersActive); %> 
        <% if (model.readOnly) numericTextBoxnumericTextBox = numericTextBox.InputHtmlAttributes(new { @readonly = "readonly"disabled = "disabled" }); %> 
        <%= numericTextBox%> 
 
Does not show the desired effect.
I have read the other thread using java script. But I am looking for a simpler solution and use javaScript only in cases where it is inevitable.

3 Answers, 1 is accepted

Sort by
0
Diiimo
Top achievements
Rank 1
answered on 08 Aug 2010, 08:22 PM
Hello,

have you found a solution for this?
0
Frank Michael
Top achievements
Rank 1
answered on 09 Aug 2010, 12:36 PM
This is my solution

<%@ Control Language="C#" Inherits="WorkstreamPlatform_WebRole.Views.PlatformNumericTextBox"
CodeBehind="PlatformNumericTextBox.ascx.cs" AutoEventWireup="true" %>
 
<%var model = (PlatformNumericTextBox)Model; %>
<tr>
    <td>
        <%= Html.Label(model.name)%>
    </td>
    <td>
        <%  var numericTextBox = Html.Telerik()
                .NumericTextBox()
                .Name(model.name)
                .Value(model.value)
                .MaxValue(10000)
                .MinValue(0)
                .DecimalDigits(1).DecimalSeparator(",").IncrementStep(1)
                .Spinners(model.spinnersActive); %>
       <%-- <% if (model.readOnly) numericTextBox = numericTextBox.InputHtmlAttributes(new { @readonly = "readonly", disabled = "disabled" }); %>--%>
       <%if (model.readOnly)
         { %>
          <%=Html.TextBox(model.name,model.value, new { @readonly = "readonly", disabled = "disabled" }) %>
       <%}
         else
         { %>
        <%= numericTextBox%>
        <%} %>
    </td>
    <td>
        <span class="error"><%= model.message%></span>
    </td>
</tr>
0
Jonisan
Top achievements
Rank 1
answered on 11 Mar 2012, 11:23 PM
Hello ,

I have a problem close to this , I cant disable the numeric text box because I need the input to be send to the server on post , 
I only don't want it not editable when I have some conditions , so I need to do it from javascript . My problem is when I set the numeric text box as read only ,  the spinner is active .. How can I disable the spinner from javascript on a read only control . ?!
 
Tags
NumericTextBox
Asked by
Frank Michael
Top achievements
Rank 1
Answers by
Diiimo
Top achievements
Rank 1
Frank Michael
Top achievements
Rank 1
Jonisan
Top achievements
Rank 1
Share this question
or