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

Reset RadTextBox value to default on client

3 Answers 223 Views
Input
This is a migrated thread and some comments may be shown as answers.
Craig Wallace
Top achievements
Rank 1
Craig Wallace asked on 11 Oct 2013, 09:39 AM
How can I reset a RadTextBox to its configured EmptyMessage value using JavaScript?

Note, I want to use the property value without having to state it twice.

Thanks.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 11 Oct 2013, 10:47 AM
Hi Craig,

Please check the following code I tried to clear the RadTextBox content and display the empty message.

ASPX:
<telerik:RadTextBox ID="RadTextBox1" runat="server" EmptyMessage="Enter Name">
</telerik:RadTextBox>
<telerik:RadButton ID="RadButton1" runat="server" Text="Clear Textbox" AutoPostBack="false"
    OnClientClicked="clearTextbox">
</telerik:RadButton>

JavaScript:
<script type="text/javascript">
    function clearTextbox(sender, args) {
        var radtextbox = $find('<%=RadTextBox1.ClientID %>');
        radtextbox.clear();
    }
</script>

Thanks,
Shinu.
0
Saif
Top achievements
Rank 1
answered on 13 Feb 2019, 01:58 PM

Is there a way that i can clear all controls from radwizard at once???

 

0
Rumen
Telerik team
answered on 13 Feb 2019, 02:53 PM
Hello,

There is no such direct method to get the RadTextBox collection, but you can try the following approach to meet your scenario:


function GetRadTextBoxes()
{
    var allRadTextBoxes = [];
    var allRadControls = $telerik.radControls;
    for (var i = 0; i < allRadControls.length; i++)
    {
        var element = allRadControls[i];
        var isRadTextBox = element instanceof Telerik.Web.UI.RadTextBox;
        if (isRadTextBox)
         {
            Array.add(allRadTextBoxes, element);
         }
    }
 alert(allRadTextBoxes.length);
}

Once you have all textboxes you can clear them.

The solution is based on How-to create a javascript array of all particular RadControls on the page.
 

Best regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Input
Asked by
Craig Wallace
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Saif
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or