how do i make spinning buttons functional when radnumerictextbox is in readonly mode..?

1.2k Views Asked by At

how do i make spinning buttons functional when radnumerictextbox is in readonly mode..?

I am using Telerik's with spinning Buttons... i need RadNumericTextBox is in Readonly mode but it need to update with spinning buttons...

<telerik:RadNumericTextBox ID="radntxt_TimePickers" AutoPostBack="false" runat="server"
                                MinValue="1" MaxValue="20" ClientEvents-OnValueChanged="radntxt_TimePickers_CreateTimePickers" 
                                NumberFormat-AllowRounding="true" NumberFormat-DecimalDigits="0" NumberFormat-GroupSeparator="" 
                                IncrementSettings-InterceptMouseWheel="true" Width="40px" ShowSpinButtons="true" ReadOnly="true">
                               </telerik:RadNumericTextBox>
2

There are 2 best solutions below

0
On

I added an OnKeyPress client-side event to the textbox then added a Javascript function to cancel the event

    <telerik:radnumerictextbox id="RadTextBox1" showspinbuttons="true" runat="server">  
         <ClientEvents OnKeyPress="OnKeyPress" />  
    </telerik:radnumerictextbox> 
<!-- begin snippet: js hide: false console: true babel: false -->

<script type="text/javascript"> 
function OnKeyPress(sender, eventArgs) 
{ 
   eventArgs.set_cancel(true);    
} 
</script> 

3
On

It sounds like you want to make it readonly or not along with the spinning buttons.

You could use the code found here to make it readonly: http://www.telerik.com/community/forums/aspnet-ajax/input/radtextbox-set-read-only.aspx

Set it to false to make it editable.

<script type="text/javascript">  
function setReadOnly()  
{  
    var TextBox1 = $find("<%= RadTextBox1.ClientID %>");  
    TextBox1._textBoxElement.readOnly = true;  
}  
</script>

Note that $find is specifically for ASP.NET