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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:50:44+00:00 2026-05-14T07:50:44+00:00

I am trying to create a Validation in a reusable fashion. Purpose: Make the

  • 0

I am trying to create a Validation in a reusable fashion.

Purpose:
Make the validation control reusable.

Error Provider should associate with control passed dynamically and can be set or cleared at run time.

When user press OnClick event then all the controls gets validated with their own Error Providers.

public bool IsFieldEmpty(ref TextBox txtControl, Boolean SetErrorProvider,string msgToShowOnError)
{
    ErrorProvider EP = new ErrorProvider();
    if (txtControl.Text == string.Empty)
    {
        if(SetErrorProvider==true)
            EP.SetError(txtControl, msgToShowOnError);
        return true;
    }
    else
    {
        if(SetErrorProvider==true)
            EP.Clear();
        return false;
    }
}

Issue:

Every time the function is called new errorprovider object gets created which i dont want.
Every control should not have more than 1 error provider and i should be able to search it just like as done in asp.net to search for some control on a Page.

How can I do this

  • 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-14T07:50:44+00:00Added an answer on May 14, 2026 at 7:50 am

    In most cases you really only need one instance of ErrorProvider on a form.

    E.g.

    ErrorProvider errorProvider1 = new ErrorProvider();
    

    or just drag one from the toolbox onto the form.

    When calling an ErrorProvider, you supply the control and the message,,

    errorProvider1.SetError (dateTimePicker1, "HEY BAD DATE");
    

    To clear the error…

    errorProvider1.SetError (dateTimePicker1, "");
    

    So, one ErrorProvider instance is all you really need in most situations.

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

Sidebar

Related Questions

I am trying to create a validation that checks to make sure a domain/url
I'm trying to create a custom validation method in JQuery and I can't manage
I am trying to create a new custom validation in which I can compare
I'm trying to create a method that will custom validate any TextBox control passed
Im trying to create a simple input box with form validation, but im not
I'm trying to create a simple custom validator for my project, and I can't
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying to create a regex validation attribute in asp.net mvc to validate
I'm trying to create a Rails 3 validation that will ensure that people are
I'm trying to create a validation expression that checks the length of an input

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.