clear asp controls

Posted on 2011-10-12
Last Modified: 2012-05-12
i have a aspx page with asp textbox, dropdown controls, i would like it to reset the values, for example clear the user typed value in the text box in a button click event or post back. what would be best way to achieve this?
Question by:singsunn
    LVL 17

    Accepted Solution

    You have couple of ways to do this either with jquery OR from code behind page
    1) Using code behind
      Write function clear_data () which will clear the values and call this function on button click
    2) Jquery
          // .... clear textbox values

    Author Comment

    ok. if i were to do it in the code behind, i tried setting txtTextBox1 = string.empty but control retains the value.
    LVL 17

    Expert Comment

    try like this
    txtTextBox1.Text = "";

    Author Comment

    yes i meant txtTextBox1.Text

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now