Tuesday, 6 January 2015

How to clear data in asp.net using Javascript

Write in header section of page
 
<script type="text/javascript">
        function funClearField() {
            document.getElementById("<%= txt_DwL_ID.ClientID  %>").value = "";
            document.getElementById("<%= txt_Designation.ClientID  %>").value = "";
            document.getElementById("<%= txt_LeaveName.ClientID  %>").value = "";
            document.getElementById("<%= txt_LeaveNOD.ClientID  %>").value = "";
            document.getElementById("<%= lbl_Msg.ClientID  %>").innerHTML = "";
            return false;
        }
    </script>


Write in body section of page

<asp:Button ID="btn_Reset" runat="server" Text="Reset" Width="15%"  OnClientClick="return funClearField();"/>

No comments: