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 6372115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:11:34+00:00 2026-05-25T01:11:34+00:00

In a nutshell, let’s say I have two textboxes, both have RequiredFieldValidator controls. I

  • 0

In a nutshell, let’s say I have two textboxes, both have RequiredFieldValidator controls. I want to display only a single string in ValidationSummary control if both of the values are not valid and one string, in the place of RequiredFieldValidator if only one is not valid.

Currently, What I have is working but it is a bit messy. Was wondering if there is easier, more elegant way, of doing this.

        if ((!Text1Valid.IsValid) && (!Text2Valid.IsValid))
        {
            // Make sure the individual validator shows nothing and ValidationSummary is visible.
            Text1Valid.Display = ValidatorDisplay.None;
            Text2Valid.Display = ValidatorDisplay.None;
            ValidSummary.Visible = true;

            Text1Valid.ErrorMessage = "Both of the values are wrong!";
            Text2Valid.ErrorMessage = String.Empty;
        }
        else
        {
            // Single validation strings visible and ValidationSummary hidden.
            Text1Valid.Display = ValidatorDisplay.Dynamic;
            Text2Valid.Display = ValidatorDisplay.Dynamic;
            ValidSummary.Visible = false;

            Text1Valid.ErrorMessage = "The value is wrong.";
            Text2Valid.ErrorMessage = "The value is wrong.";
        }
  • 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-25T01:11:35+00:00Added an answer on May 25, 2026 at 1:11 am

    There definitely is not an out of box way to do what you want in a an easier/elegant fashion that I’m aware of. In terms of custom code it’s a bit difficult to get a really elegant solution because the validation logic is very coupled. I can totally imagine the situation where you have a variety of validators on each input, differing numbers of “linked” inputs, and different types of input elements. If this is a one off situation, a solution similar to yours is probably ok. If this is a recurring theme for you project then you probably want to think about how much time you can afford to invest into a more robust solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've always been confused/unsure about how .Net copies references. Let's say I have a
In a nutshell , I want to have different faces for some types of
In a nutshell, there's a global stylesheet: a { font-family: Arial; } I want
In a nutshell: I want to do the same thing Dependency Walker does. Is
In a nutshell, I have a solution that builds fine in the IDE, and
I have set up a HashMap like so: Map<String, ArrayList<String>> theAccused = new HashMap<String,
In a nutshell, I want my JQuery UI Slider to look like this: Is
In a nutshell: Using jquery I want to get some xml output and use
I have wrote a web service, in a nutshell it uses openpop to get
I have this code copied from C# 4.0 in a nutshell that uses Attribute/Reflection

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.