By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,581 Members | 1,990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,581 IT Pros & Developers. It's quick & easy.

C#NET2008 DataValidation using IF statement

100+
P: 126
Hullo Good Friends,
I am back again seeking help. Please help me.
I am using C#NET2008 Window Application, This is the situation. Should either one of this control, txtXMLFolder.Text , txtXMLName.Text , lblCustID.Text is BLANK, It should not activate FCreateXMLFile() Function.


I am using IF Statement to validate data and it generate this error message to my surprise.

Error 2 Operator '||' cannot be applied to operands of type 'bool' and 'string'

This is the coding that I tried to:
Expand|Select|Wrap|Line Numbers
  1.  
  2. private void btnXML_Click(object sender, EventArgs e)
  3.  {  //validate data pior to create XML File
  4.  
  5.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text = ""))
  6.     {
  7.      string txtmsg = "Either one of these data is missing" + "\n";
  8.      txtmsg += "Customer Selection" + "\n";
  9.      txtmsg += "XML File Creation" + "\n";
  10.      txtmsg += "Select XML Stored Folder";
  11.  
  12.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  13.    }
  14.    else
  15.      {//create XML File 
  16.        FCreateXMLFile();
  17.      }
  18.  } // end btnXML
  19.  
Oct 25 '10 #1

✓ answered by Anton Zinchenko

Expand|Select|Wrap|Line Numbers
  1. private void btnXML_Click(object sender, EventArgs e)
  2.  {  //validate data pior to create XML File
  3.  
  4.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text == ""))
  5.     {
  6.      string txtmsg = "Either one of these data is missing" + "\n";
  7.      txtmsg += "Customer Selection" + "\n";
  8.      txtmsg += "XML File Creation" + "\n";
  9.      txtmsg += "Select XML Stored Folder";
  10.  
  11.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  12.    }
  13.    else
  14.      {//create XML File 
  15.        FCreateXMLFile();
  16.      }
  17.  } // end btnXML
  18.  

Share this Question
Share on Google+
2 Replies


P: 16
Expand|Select|Wrap|Line Numbers
  1. private void btnXML_Click(object sender, EventArgs e)
  2.  {  //validate data pior to create XML File
  3.  
  4.    if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text == ""))
  5.     {
  6.      string txtmsg = "Either one of these data is missing" + "\n";
  7.      txtmsg += "Customer Selection" + "\n";
  8.      txtmsg += "XML File Creation" + "\n";
  9.      txtmsg += "Select XML Stored Folder";
  10.  
  11.      MessageBox.Show(txtmsg, "XML Creation Cancelled ");
  12.    }
  13.    else
  14.      {//create XML File 
  15.        FCreateXMLFile();
  16.      }
  17.  } // end btnXML
  18.  
Oct 25 '10 #2

100+
P: 126
Hi Anton,
Thank you very much for sharing information with me.
I followed your sample and my coding is working now.
You are awesome and generous in sharing information.
Appreciate that very much.

I am so glad to meet you here at this Wonderful FORUM
Oct 25 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.