title: Multiple if conditions check in single button click
body: <p>My C# code is something like as follows.</p>
  
  <pre><code>    if(TextBox1.Text.Length &gt; 5)
      {
      if(TextBox2.Text.Length &gt; 5)
      {
      if(TextBox3.Text.Length &gt; 5)
      {
      if(TextBox4.Text.Length &gt; 5)
      {
      //Action to pass to the next stage.
      }
      else
      {
      error4.text = "Textbox4 value should be minimum of 5 characters.";
      }
      }
      else
      {
      error3.text = "Textbox3 value should be minimum of 5 characters.";
      }
      }
  
  else
  {
  error2.text = "Textbox2 value should be minimum of 5 characters.";
  }
  }
  else
  {
  error1.text = "Textbox1 value should be minimum of 5 characters.";
  }
  </code></pre>
  
  <p>1) In the above kind of sample. I am using nested If-Else concept where on button click, if TextBox1 value is less than 5 is moves to else part and shows the error1 value but it will not check for further errors.</p>
  
  <p>2) If I change If conditions to step by step If conditions then it will not work for me because the action must be done only if all the IF conditions satisfies.</p>
  
  <p>3) If I use &amp;&amp; operator to check all conditions I will not get individual error to each "error label"</p>
  
  <p>How can I check multiple IF conditions on a single button click?</p>
  
  <p><strong>My original code</strong></p>
  
  <pre><code>if (checkavail == "available")
          {
              if (name.Text.Length &gt; 0)
              {
                  if (email.Text.Length &gt; 5)
                  {
                      if (password1.Text.Length &gt; 7 &amp;&amp; password1.Text == password2.Text)
                      {
                          if (alternate.Text.Contains("@") &amp;&amp; alternate.Text.Contains("."))
                          {
                              if (question.Text.Length &gt; 0)
                              {
                                  if (answer.Text.Length &gt; 0)
                                  {
                                      Response.Redirect("next_page.aspx");
                                  }
                                  else
                                  {
                                      error5.Text = "Please enter your security answer";
                                  }
                              }
                              else
                              {
                                  error4.Text = "Please enter your security question";
                              }
                          }
                          else
                          {
                              error3.Text = "Invaild alternate email address";
                          }
                      }
                      else
                      {
                          error2.Text = "Password should be minimum 8 characters and must match confirm password";
                      }
                  }
                  else
                  {
                      error1.Text = "Email address should be minimum 6 characters";
                  }
              }
              else
              {
                  error.Text = "Please enter your name";
              }
          }
          else
          {
              error1.Text = "This email address is already taken. Please try another";
          }
  </code></pre>
  
  <p>I need the Redirect action to be done upon satisfying all conditions. If more than one error was found each error should get each error message.</p>