Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:24:59+00:00 2026-05-27T20:24:59+00:00

My C# code is something like as follows. if(TextBox1.Text.Length > 5) { if(TextBox2.Text.Length >

  • 0

My C# code is something like as follows.

    if(TextBox1.Text.Length > 5)
    {
    if(TextBox2.Text.Length > 5)
    {
    if(TextBox3.Text.Length > 5)
    {
    if(TextBox4.Text.Length > 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.";
}

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.

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.

3) If I use && operator to check all conditions I will not get individual error to each “error label”

How can I check multiple IF conditions on a single button click?

My original code

if (checkavail == "available")
        {
            if (name.Text.Length > 0)
            {
                if (email.Text.Length > 5)
                {
                    if (password1.Text.Length > 7 && password1.Text == password2.Text)
                    {
                        if (alternate.Text.Contains("@") && alternate.Text.Contains("."))
                        {
                            if (question.Text.Length > 0)
                            {
                                if (answer.Text.Length > 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";
        }

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:24:59+00:00Added an answer on May 27, 2026 at 8:24 pm

    Thanks to all. I found my answer in below manner

    string p1, p2, p3, p4;
            if (TextBox1.Text.Length > 5)
            {
                p1 = "pass";
                Label1.Text = "";
            }
            else
            {
                Label1.Text = "Textbox1 value should be minimum 5 characters.";
                p1 = "fail";
            }
            if (TextBox2.Text.Length > 5)
            {
                p2 = "pass";
                Label2.Text = "";
            }
            else
            {
                Label2.Text = "Textbox2 value should be minimum 5 characters.";
                p2 = "fail";
            }
            if (TextBox3.Text.Length > 5)
            {
                p3 = "pass";
                Label3.Text = "";
            }
            else
            {
                Label3.Text = "Textbox3 value should be minimum 5 characters.";
                p3 = "fail";
            }
            if (TextBox4.Text.Length > 5)
            {
                p4 = "pass";
                Label4.Text = "";
            }
            else
            {
                Label4.Text = "Textbox4 value should be minimum 5 characters.";
                p4 = "fail";
            }
            if (p1 == "pass" && p2 == "pass" && p3 == "pass" && p4 == "pass")
            {
                Status.Text = "All pass";
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My HTML form is something like as follows <form id=form1 name=form1 method=post action=> number:
How is your javaScript code organized? Does it follow patterns like MVC, or something
I work on code something like this ... HEADERS ... int *var; void child()
I occasionally write code something like this: // file1.cpp #define DO_THIS 1 #if DO_THIS
I often find I want to write code something like this in C#, but
What tool or method can I use to see what code something like an
I've got an HTML select element which I'm updating dynamically with code something like
The code goes something like this: protected bool IsOKToSend() { bool IsOK = true;
My code has something like this: HttpFileCollection files Instead of looping through each file
my code is something like this //css li{display:inline-block} //html #li margin and width are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.