C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...







How to Empty all the text box in the form


Posted Date: 15 May 2008    Resource Type: Code Snippets    Category: C# Syntax

Posted By: Abhishek Arya       Member Level: Diamond
Rating:     Points: 10



The following function shows how to Empty all the text box in the form


private void ClearTextBoxes()
{
foreach (Control txt in this.Controls)
{
if (txt.GetType() == typeof(System.Windows.Forms.TextBox))
{
txt.Text = "";
}
}
}




Responses

Author: satyendra kr. Pandit    16 May 2008Member Level: Bronze   Points : 2
//Clear all the textboxs on a form
public void ClearFields()
{
foreach (Control ctl11 in this.FindControl("Form1").Controls)
{
if (((!object.ReferenceEquals(ctl11, System.DBNull.Value))))
{
if ((ctl11.ToString().ToLower().IndexOf("textbox") > 0))
{
((TextBox)ctl11).Text = "";
//((CheckBox)ctl11).Checked = false;

}

}
}
}


Author: mani kumar.k.m    16 May 2008Member Level: Gold   Points : 2


protected void btnClear_Click(object sender, EventArgs e)
{
Clear();
}

public void Clear()
{

foreach (Control ctrl in this.Controls)
{
if (ctrl is HtmlForm)
{
foreach (Control sctrl in ctrl.Controls)
{
if (sctrl is TextBox)
{
TextBox txb = sctrl as TextBox;
txb.Text = "";
}
}
}
}
}





Author: karthik    16 May 2008Member Level: Diamond   Points : 2
Also use in
text.text=string.empty
or

text.text=nothing


Author: RamyaNaidu    06 Aug 2008Member Level: Silver   Points : 0
textbox.text="";


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to find the differnce between two dates in days
Previous Resource: How to create a Function for adding Html tag with the selected text
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use