[RESOLVED]clear textbox with different id


I have asp.net textboxes width different IDs.

I would like to add linkbutton that will clear all textboxes in the page dynamically.

or other option is to clear all the asp.net form, think it should be easier.

How can I do that?


Checkout the post below. From javascript you can reset the form as follows:




may be you can try out this,

 $(‘#form_id :text).val(”);

Hi borisre,

Thanks for your post.


I would like to add linkbutton that will clear all textboxes in the page dynamically.

As for your problem, you could refer to the following sample to empty TextBoxes.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="../../Scripts/jquery-1.8.2.js"></script>
        $(function () {
            $("#BtnClean").click(function () {
                return false;
    <form id="form1" runat="server">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
        <br />
        <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
        <br />
        <asp:LinkButton ID="BtnClean" runat="server">Clean</asp:LinkButton>

If you have any question  about this issue, please post back freely.

Best Regards,

Fei Han

thanks, it worked great, but I keep on getting the following error after using it:

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Leave a Reply