jQuery to Reset or Clear all Asp.Net or HTML controls placed on web form

  ASP.NET Projects

ASPX Complete Code:-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Reset all fields using jQuery</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
        function resetAllControls() {
            $("#form1").find('input:text, input:password, input:file, select, textarea').val('');
            $("#form1").find('input:radio, input:checkbox').prop('checked', false).prop('selected', false);
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <fieldset style="width: 370px">
                <legend>Application form</legend>
                <div>
                    <table cellspacing="2">
                        <tr>
                            <td>Full Name </td>
                            <td>
                                <asp:TextBox ID="txtFullName" runat="server"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>Email </td>
                            <td>
                                <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>Gender </td>
                            <td>
                                <asp:RadioButton ID="rbMale" Text="Male" runat="server" GroupName="gender" />
                                <asp:RadioButton ID="rbFemale" Text="Female" runat="server" GroupName="gender" /></td>
                        </tr>
                        <tr>
                            <td>Nationality </td>
                            <td>
                                <asp:DropDownList ID="ddlNationality" runat="server" Width="173px">
                                    <asp:ListItem Text="-Select-" Value="0"></asp:ListItem>
                                    <asp:ListItem Text="Indian" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="Others" Value="2"></asp:ListItem>
                                </asp:DropDownList></td>
                        </tr>
                        <tr>
                            <td>Skills </td>
                            <td>
                                <asp:CheckBoxList ID="cblSkills" runat="server" RepeatColumns="2">
                                    <asp:ListItem Text="Asp.Net" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="MVC" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="jQuery" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Sql Server" Value="4"></asp:ListItem>
                                </asp:CheckBoxList></td>
                        </tr>
                        <tr>
                            <td>Post applying for </td>
                            <td>
                                <asp:RadioButtonList ID="rblApplyingFor" runat="server" RepeatColumns="2">
                                    <asp:ListItem Text="Trainee" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="Team Leader" Value="2"></asp:ListItem>
                                    <asp:ListItem Text="Software Engineer" Value="3"></asp:ListItem>
                                    <asp:ListItem Text="Project manager" Value="4"></asp:ListItem>
                                </asp:RadioButtonList></td>
                        </tr>
                        <tr>
                            <td>Upload Resume:</td>
                            <td>
                                <asp:FileUpload ID="fuResume" runat="server" /></td>
                        </tr>
                        <tr>
                            <td>Paste your resume  </td>
                            <td>
                                <asp:TextBox ID="txtResume" runat="server" Columns="34" Rows="4" TextMode="MultiLine"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:CheckBox ID="cbNotify" runat="server" Text="Notify me the status via Email" /></td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <asp:RadioButton ID="rbAgree" runat="server" Text="I agree to terms & conditions" /></td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
                                <asp:Button ID="btnReset" runat="server" Text="Reset" OnClientClick="resetAllControls();" />
                            </td>
                        </tr>
                    </table>
                </div>
            </fieldset>
        </div>
    </form>
</body>
</html>

 

7 thoughts on - jQuery to Reset or Clear all Asp.Net or HTML controls placed on web form

  • Eco-cleaning

    HI.
    In modern the companies work competent specialists.

    Cleaning international company Cleaning service appeared total-only 6 years ago, this notwithstanding swift dynamic mprovement still does not cease surprise all ours rivalsandnew customers , however practically none special secret in the swift improvement of our firms notavailable.
    Despite on the impressive practical gained experience, service staff systematically enhances his qualification on diverse training and on courses. Listed assist perfect measure master new equipment and equipment .

    Employees of our company are ready to provide professional cleaning services such as:

    General cleaning apartments, workshops , stores and offices
    Daily maintenance of cleanliness in the room
    Deep cleansing and decorative treatment of floors slip prevention
    Putting order after repair and construction work
    Chemical cleaning of all types of carpet
    Cleaning exterior glass surfaces, cleaning building facades
    Seasonal cleaning outside the building
    Disposal of trash and snow under license.

    And likewise you can order:

    Mattress cleaning, Postconstruction cleaning, Cleaning and tidying up., Corporate cleaning, Professional house cleaning, Best house cleaning, Marble care]

    We commit cleaning only special cleaning supply. Fast increase in the number of cleaning firms in Prospect Hights proves that and in the area represented learned to appreciate own free time.
    Serving around Williamsburg AND ON ALL STREETS, SUCH AS: High Bridge, Throgs Neck, City Line , Waterside Plaza, Grasmere .

    And so exclusively you can here be sure, come in specified site and make an order services .

  • Hello All
    Thanks for checking out my about page. My name is Darren Farrell.
    I have worked a long time in this niche. My interest in writing started at a young age. I wrote poetry as a child and eventually went on to work with my school newspaper.
    This early tryst into journalism eventually led me to academic writing. There is plenty of work for qualified writers. I specialize in essays, but have the skills to do all types of academic writing.
    Email me for more information about rates and a price quote. I’m looking forward to helping you.

    Academic Writer – Darren Farrell – improvepalmdaleschools.org Band

  • I’m an academic writer who loves to bring smiles to people’s face.

    Writing is what I do for a living and I am so passionate about this. I have worked with several organizations whose goal is to help people solve problems.
    I love traveling and have visited several places in the past few years.
    I’m happy to have written several books that have contributed positively to the lives of many. My books are available in several parts of the world. And I’m currently working with service providers that help people save energy. Being a part of this team has open more opportunities for me to excel as a writer. I have worked with different people and met many clients as a professional.
    I can handle any kind of writing project and provide nothing but the best. People come to me all the time to ask if I can solve their writing problems and I accept. I find pleasure in assisting them to solve their problems as a professional.

    Professional Writer – Alexandre Hilton – lsunion.com Band

LEAVE A COMMENT