Resetting all controls on a form

2 posts, 0 answers
  1. Joe
    Joe avatar
    23 posts
    Member since:
    Nov 2010

    Posted 26 Nov 2013 Link to this post

    I have several separate forms that I want to add a "reset" or "clear" button to. What I'd like is a way to blanket reset all controls to their initial state.

    The forms are built entirely from Telerik controls.

    What is the best to do this? I'd like the ability to use a single piece of code (javascript) to be included in all pages.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Nov 2013 Link to this post

    Hi Joe,

    Please have a look into the following code snippet to Reset the controls in RadButton Click event.

    <telerik:RadTextBox ID="text1" runat="server">
    <br />
    <telerik:RadTextBox ID="text2" runat="server">
    <br />
    <telerik:RadDatePicker ID="date1" runat="server">
    <br />
    <telerik:RadComboBox ID="RadComboBox1" runat="server">
            <telerik:RadComboBoxItem Text="I" runat="server" />
    <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="false" OnClientClicked="Clear"

    <script type="text/javascript">
        function Clear(sender, args) {
            var elements = document.getElementsByTagName("input");
            for (var i = 0; i < elements.length; i++) {
                if (elements[i].type == "text") {
                    elements[i].value = "";

Back to Top