Click here to Skip to main content
15,031,687 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hello all,
I ahve a web form where i am submitting personal information like name,age etc.when I save the information i cleared the text box values.I have also false the view state of text box.but if i have entered amit in name and save it.Second time if i fill information again something like name as arvind then the amit name is also coming down there.how to clear the previous value after postback
Posted

Hi,

Go to the design page of your screen,there you can find the
FORM tag.

You can find the AutoComplete property.Then set that value as "OFF".
Thats it.

If this property is not showing in your page also just write this property manually.

Regards,
Kiran.
   
Use AutoCompleteType property of text box.<br />
<asp:TextBox ID="TextBox1" AutoCompleteType="disabled" runat="server"></asp:TextBox>
   
Use This Function

public void EmptyControlData(Control parent)
    {
        foreach (Control c in parent.Controls)
        {
            if ((c.GetType() == typeof(TextBox)))
            {
                ((TextBox)c).Text = "";
            }
            if ((c.GetType() == typeof(DropDownList)))
            {
                ((DropDownList)c).SelectedIndex = -1;
                //((DropDownList)c).Items.Clear();
            }
            if (c.HasControls())
            {
                EmptyControlData(c);
            }
        }
    }


Here parent is this.
   
Comments
Hiren solanki 27-Oct-10 7:37am
   
good way to clearize using javascript.
Hi,

This problem is called the Cacheing the browser data(Read Cache concept in ASP.NET).
You can solve this problem by making AutoComplete property of Form Tag of your page set as "OFF".

or

you need to clear the your page Cache data manually.

Regards,
Kiran.
   
Comments
AmitChoudhary10 27-Oct-10 7:33am
   
i am also facing same problem,i don't want user to see past records filled in text boxes.From where can i set AutoCompleteProperty to off?...
Example:
if (IsPostBack)
        {
          textbox1.text = "";
         }
   
clear the textbox after display message using javascript in asp.net
   
add in form tag other wise set the textbox property autocomplete="off"
   
set the textbox property autocomplete="off"
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900