This is a migrated thread and some comments may be shown as answers.
RadNumericTextBox with ReadOnly
4 Answers 128 Views
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 01 Mar 2011, 11:02 PM

I am using RadControls for ASP.NET Ajax Q2 2010 NET 35  (2010.2.826.35)
I have set the radNumericTextbox ReadOnlyStyle as

<telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server" 
      DataType="System.Int32"  MaxValue="5000" MinValue="0" 
      SelectionOnFocus="None" Skin="Sunset" Width="50px" Enabled="false">
       <DisabledStyle BackColor="#EEEEEE" />
       <ReadOnlyStyle BackColor="#EEEEEE" />
       <EnabledStyle HorizontalAlign="Center" />
      <NumberFormat DecimalDigits="0" />
</telerik:RadNumericTextBox>

When I  set the enable to true and readOnly to false on client side  as

function EnableRadNumericTextBox1(enable) {
    var RadNumericTextBox1= $("div #divReqPositions [id$='RadNumericTextBox1']")[0].control;
       
    if (enable) {
        RadNumericTextBox1.enable();
        RadNumericTextBox1._textBoxElement.readOnly = false;
    }
    else {
        RadNumericTextBox1.clear();
        RadNumericTextBox1.disable();
    }

If the rad control has value and I need to change the style to enabling style (Enable= true,ReadOnly= false)  on client side by using the javascript function above the background of the control (RadNumeric control) stay gray untill I move the mouse over the control.


any help would be appreciated.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 03 Mar 2011, 01:12 PM
Hello Sam,


Try accessing the NumericTextBox, using $find() method as described in the documentation.
Client-Side Basics

Also refer the following link o know more about client side methods of RadNumericTextBox.
RadNumericTextBox Client Object


Thanks,
Princy.
0
Sam
Top achievements
Rank 1
answered on 03 Mar 2011, 10:20 PM
I am using Ajax and RadScriptManager and referencing JS files in RadscriptManager. So I can't use this
var dateInput = $find("<%= RadDateInput1.ClientID %>"); to find a control in JS file
Please correct me if I am wrong.
0
Princy
Top achievements
Rank 1
answered on 04 Mar 2011, 11:39 AM
Hello Sam,
Javascript external files are not run through the ASP.NET engine, so the server tag <%=...%> is never executed in that case. In order to access any control ClientID, use a global variable in the aspx file itself, and save the ClientID when page loads.  Now you will be able to access the control (from external JS file) using the ClientID saved in global variable.

Another option is to  take the ID of the control from the rendered output and hardcode it where you need it.
Thanks,
Princy.
0
Sam
Top achievements
Rank 1
answered on 07 Mar 2011, 04:55 PM
But again I am using RadScriptManager and RadAjaxManager and the RadNuericTextBox control is inside WebUserControl; now the RadScriptManager And ajaxManager is in the aspx page.
I have tried to create a global javascript for the control  in ascx page as

 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
  
 <script type="text/javascript">  
  
  var  RadNumericTextBox1= $find("<%= RadNumericTextBox1.ClientID %>");
  
 </script
  
</telerik:RadCodeBlock>


 

and on radiobuttonlist click event  I get null for the RadNumericTextBox1

function onRadioClick()
{
  RadNumericTextBox1.enable();
 // here the RadNumericTextBox1 is null
}

Tags
Input
Asked by
Sam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Sam
Top achievements
Rank 1
Share this question
or