Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6552379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:27:11+00:00 2026-05-25T12:27:11+00:00

In the below code TextBox value is not getting cleared after clicking on Button.

  • 0

In the below code TextBox value is not getting cleared after clicking on Button.

Default.aspx

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <br />
    <asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="20">
    </asp:Timer>
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <Triggers>
                <asp:AsyncPostBackTrigger controlid="Timer1" eventname="Tick" />
            </Triggers>
        <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    <asp:Repeater ID="Shout_Box" runat="server">
            <ItemTemplate>
               <%# DataBinder.Eval(Container.DataItem, "Message") %>
            </ItemTemplate>
        </asp:Repeater>

        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:TextBox ID="TextBox1" runat="server">
        </asp:TextBox>
    </form>
</body>
</html>

C# code for button click.

protected void Button1_Click(object sender, EventArgs e)
{
    string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=repeater;" + "UID=root;" + "PASSWORD=********;" + "OPTION=3";
    OdbcConnection MyConnection = new OdbcConnection(MyConString);
    OdbcCommand cmd = new OdbcCommand("INSERT INTO table1(message)VALUES(?)", MyConnection);
    cmd.Parameters.Add("@email", OdbcType.VarChar, 255).Value = TextBox1.Text;
    MyConnection.Open();
    cmd.ExecuteNonQuery();
    MyConnection.Close();
    TextBox1.Text = "";
}

I tried adding a line as above TextBox1.Text = ""; to clear text but no use.
Please do not ask me to keep Button outside the updatepanel tag. I need the event to be done without posting back the page.

If TextBox is inside Due to timer trigger for ever 20 fsecs the textbox is too blinking and not allowing to edit. To say simply TextBox is refreshing and not allowing even a single bit of text to add.

I don’t want to extend this to JavaScripts and other to clear a value in textbox. Can anybody tell me how to clear the textbox value using C#.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:27:12+00:00Added an answer on May 25, 2026 at 12:27 pm

    Use another update panel and in Page_Load function add UpdatePanedid.Update(); Hope this helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my below code when is button clicked the textbox value is being added
I have written below code to check for blank value in my textbox but
The code below works fine but, in the textbox the decimal value has this
The below code in Java throws Null pointer exception. public class New{ int i;
How do I use WriteByte? The below code will not work, coming up with
Below is my code present in my application : <input id=input value=Testing /> <a
Hi Below is the code i m using for login page.but it does not
I need to validate a textbox, so it's value consist of 10 characters (not
A Submit button for a form located on my page triggers the code below,
When I use the code below its alerting a blank value? why is that?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.