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

Clear RadNumericTextBox with JavaScript?

5 Answers 467 Views
Input
This is a migrated thread and some comments may be shown as answers.
Testman
Top achievements
Rank 1
Testman asked on 15 Jul 2010, 10:17 AM
I have looked at several different examples of how to clear a RadNumericTextBox with JavaScript, but for some reason I can't get them to work. I created a small sample page that I have included below. Could someone show me how to write an onlick-script so that the button clears the textbox.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title>Test RadNumericTextBox</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadNumericTextBox ID="numeric" runat="server" />
        <input type="button" value="Clear" />
        <asp:ScriptManager ID="manager" runat="server" />
    </div>
    </form>
</body>
</html>

5 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 Jul 2010, 10:47 AM
Hello,


Have you tried clear() method to clear the RadNumericTextBox value?

aspx:
<telerik:RadNumericTextBox ID="numeric" runat="server" />
<input type="button" value="Clear" onclick="clearText();" />

client code:
<script type="text/javascript">
    function clearText() {
        var numeric = $find("<%= numeric.ClientID %>");
        numeric.clear();
    }
</script>


-Shinu.
0
Testman
Top achievements
Rank 1
answered on 15 Jul 2010, 12:49 PM
Managed to solve it in a similar fashion by myself. But thanks for the help anyway.
0
Rapitoloco
Top achievements
Rank 1
answered on 07 Sep 2010, 10:58 PM
Hey bru, how did you solve it man? I facing the same problem and the .clear() method doesn't work, thanks!!
0
Shinu
Top achievements
Rank 2
answered on 08 Sep 2010, 08:29 AM
Hello Luis,

These are the alternatives I found for clearing NumericTextBox.

Client code:
function clearText() {
    var numeric = $find("<%= numeric.ClientID %>");
    //    numeric._textBoxElement.value = "";  // for clearing text
    //    numeric.set_value("");               // for clearing text
    //    numeric.set_textBoxValue("");        // for clearing text
    numeric.clear();
}

Also the most important client methods for NumericTextBox (ASP.NET AJAX version) is shown in the following documentation:
RadNumericTextBox Client Object


Could you tell us which version of RadControls that you are using, if this does not help?


-Shinu.
0
Rapitoloco
Top achievements
Rank 1
answered on 08 Sep 2010, 04:26 PM
Hi, I was doing things wrong sorry, just to let you know that IT WORKS, was my bad... but hey it's human thing to recognize our mistakes, hehe have a great day!!
Tags
Input
Asked by
Testman
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Testman
Top achievements
Rank 1
Rapitoloco
Top achievements
Rank 1
Share this question
or