I have written a code for validating text boxes as follows
public class TestClass
{
public void RequiredText(TextBox txt, ToolTip newtoolTip)
{
if (txt.Text != string.Empty)
{
//txt.Text = "Required";
txt.BackColor = System.Drawing.Color.White;
newtoolTip.Hide(txt);
}
else
{
txt.BackColor = System.Drawing.Color.Tomato;
newtoolTip.Show("Required", txt);
}
}
}
In textbox validating i use this
private void textBox2_Validating(object sender, CancelEventArgs e)
{
TestClass test = new TestClass();
test.RequiredText(textBox2, toolTip1);
}
Now what i need is when i click on submit i would like to display error message for the text boxes that are left empty . If success i would like to save the record. Any idea please
Display an error with tool tip
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.


CrishRank #1,487 · 1.1K reputationPosted Jun 21, 2010, 2:45 AM EDT
If you want to alert message run time then check each textbox not null else insert your values in textbox. If any value is null then set flag is true. Check flag is true then show message else insert values.
thanks
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 21, 2010, 2:47 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Jun 21, 2010, 5:05 AM EDT