RadNumericTextBox with ReadOnly

5 posts, 0 answers
  1. Sam
    Sam avatar
    11 posts
    Member since:
    Jan 2010

    Posted 01 Mar 2011 Link to this post

    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.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Mar 2011 Link to this post

    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.
  3. Sam
    Sam avatar
    11 posts
    Member since:
    Jan 2010

    Posted 03 Mar 2011 Link to this post

    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.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2011 Link to this post

    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.
  5. Sam
    Sam avatar
    11 posts
    Member since:
    Jan 2010

    Posted 07 Mar 2011 Link to this post

    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
    }

Back to Top