Hi... I have created two text boxes I want that if user enter value in first text box and also in second text box. If user not enters any value neither first text box nor second text. Then he would get an error message.
You can do changes in below code that I have.
Code:
protected void Button1_Click(object sender, EventArgs e)
{
if (Label1.Text.StartsWith(TextBox1.Text))
{
MessageBox.Show(TextBox1.Text, "Found");
}
else
{
if (Label1.Text.EndsWith(textbox2.Text))
{
MessageBox.Show(textbox2.Text, "Found");
}
else
{
MessageBox.Show("Not Found");
}
}
}
If Condition?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Sandeep Pant117 reputationPosted Jul 7, 2011, 9:09 PM EDT
{
if(textBox1.Text.Trim().Length==0)
{
MessageBox.Show("Enter text in textBox1");
}
if (textBox2.Text.Trim().Length==0)
{
MessageBox.Show("Enter text in textBox2");
}
else
{
MessageBox.Show("OK you have filled both textbox");
}
}
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Jul 7, 2011, 10:18 PM EDT
use required field Validator to both controls....