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

RadMaskedTextBox set_value method throws exception

3 Answers 86 Views
Input
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 08 Aug 2013, 08:35 PM
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?

3 Answers, 1 is accepted

Sort by
0
A2H
Top achievements
Rank 1
answered on 08 Aug 2013, 10:39 PM
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
0
Bruce
Top achievements
Rank 1
answered on 09 Aug 2013, 03:22 PM
I get the same thing with the .clear() method, "0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'clear'".
0
Accepted
A2H
Top achievements
Rank 1
answered on 09 Aug 2013, 03:54 PM
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

Tags
Input
Asked by
Bruce
Top achievements
Rank 1
Answers by
A2H
Top achievements
Rank 1
Bruce
Top achievements
Rank 1
Share this question
or