C#NET2008 DataValidation using IF statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    C#NET2008 DataValidation using IF statement

    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.Te xt , 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:
    Code:
     
    private void btnXML_Click(object sender, EventArgs e)
     {  //validate data pior to create XML File
    
       if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text = ""))
        {
         string txtmsg = "Either one of these data is missing" + "\n";
         txtmsg += "Customer Selection" + "\n";
         txtmsg += "XML File Creation" + "\n";
         txtmsg += "Select XML Stored Folder";
    
         MessageBox.Show(txtmsg, "XML Creation Cancelled ");
       }
       else
         {//create XML File 
           FCreateXMLFile();
         }
     } // end btnXML
  • Anton Zinchenko
    New Member
    • Sep 2010
    • 16

    #2
    Code:
    private void btnXML_Click(object sender, EventArgs e)
     {  //validate data pior to create XML File
     
       [B]if ((this.txtXMLFolder.Text == "" ) ||  (this.txtXMLName.Text == "") ||  (this.lblCustID.Text == ""))[/B]
        {
         string txtmsg = "Either one of these data is missing" + "\n";
         txtmsg += "Customer Selection" + "\n";
         txtmsg += "XML File Creation" + "\n";
         txtmsg += "Select XML Stored Folder";
     
         MessageBox.Show(txtmsg, "XML Creation Cancelled ");
       }
       else
         {//create XML File 
           FCreateXMLFile();
         }
     } // end btnXML

    Comment

    • lenniekuah
      New Member
      • Oct 2006
      • 126

      #3
      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
      Last edited by lenniekuah; Oct 26 '10, 02:02 AM. Reason: statement error

      Comment

      Working...