RadMaskedTextBox set_value method throws exception

4 posts, 1 answers
  1. Bruce
    Bruce avatar
    17 posts
    Member since:
    Mar 2013

    Posted 08 Aug 2013 Link to this post

    I have 3 RadMaskedTextBox controls in a web user control. I want to use a client side java script function to clear any entered data on a button click. I use
    var maskedTextBox = document.getElementById('<%=uxPhoneNumber.FindControl("uxAreaCode").ClientID %>');
    if (maskedTextBox != null) {
        maskedTextBox.set_value("");
    }
    to find the controls (just showing the first control), and that is returning an HTMLelement object. When I try to use either the get_value(), or set_value() methods I get a JavaScript runtime error such as, "0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'set_value'". What am I doing wrong?
  2. A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 08 Aug 2013 Link to this post

    Hello,

    You can use Rad MaskedTextBox's Clear method to remove any entered value.
    Please try the below implementation 
    function ClearMaskTextValues() {
             var maskedTextbox = $find("<%= RadMaskedTextBox1.ClientID%>");
             maskedTextbox.clear();
            }


    Thanks,
    A2H
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bruce
    Bruce avatar
    17 posts
    Member since:
    Mar 2013

    Posted 09 Aug 2013 Link to this post

    I get the same thing with the .clear() method, "0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'clear'".
  5. Answer
    A2H
    A2H avatar
    177 posts
    Member since:
    Mar 2010

    Posted 09 Aug 2013 Link to this post

    Hi,

    I guess you are using document.getElementById() to find the reference of RadMaskedTextBox in javascript.

    If you are using document.getElementById(), please change your method like given below

    function ClearMaskTextValues() {
                var $ = $telerik.$;
                var maskedTextBox = $find('<%=uxPhoneNumber.FindControl("uxAreaCode").ClientID %>');
                if (maskedTextBox != null) {
                    maskedTextBox.clear();
                }
            }


    The reason is Telerik controls  are Ajax based and to get the reference of control we need to use $find rather than document. getElementById() ,which will give and HTMLDOM element instead of  an instance of control. 

    Please refer this link for more details

    Thanks,
    A2H

Back to Top