This is my code:
protected void Button1_Click(object sender, EventArgs e)
{
string s1 = TextBox1.Text;
string s2 = TextBox2.Text;
string s3 = TextBox3.Text;
blog b = new blog();
if (TextBox3.Text.Length > 100)
{
Label2.Text = "Please enter less than 100 characters, please...";
}
else
{
Label2.Text = "Thanks for sharing...";
b.Insertblog(s1, s2, s3);
}
//I've set maxLength property of first two textboxes set to 20,20
}
By this code I've inserted data into a XML file. Data is entered. But after entering data the values remain in the textboxes. I want to clear it. How can this be done?

4 answers
protected void Button1_Click(object sender, EventArgs e)
{
blog b = new blog();
// You could always set TextBox3 Maxlength to 100 and get rid of this if....
if (TextBox3.Text.Length > 100)
{
Label2.Text = "Please enter less than 100 characters, please...";
}
else
{
Label2.Text = "Thanks for sharing...";
b.Insertblog(Textbox1.Text,Textbox2.Text, Textbox3.Text);
}
Textbox1.Text = string.Empty;
Textbox2.Text = string.Empty;
Textbox3.Text = string.Empty;
//I've set maxLength property of first two textboxes set to 20,20
}
answered 2 years ago by:
480
Its not working . any idea?
answered 2 years ago by:
226
17279
If the textboxes are not clearing, are any of them bound to a data source?
From those TextBoxes I'm inserting data to my XML file (it's in APP_DATA folder). I have two methods[GetBlig() and InsertBlog()] in my blog.cs file and as you see, I created one object instance of blog class and overloading the constructor with the values taken from those TextBoxes.
The link you can check here:
http://aspspider.info/lokhu/Memeber/Default.aspx
answered 2 years ago by:
226
17279
Is it possible that you could be reloading the textboxes with the previous data following a postback?
vulpes, I've solved the problem from your clue. The TextBoxes are databind(), so I changed the code this way:
answered 2 years ago by:
226