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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:53:01+00:00 2026-05-26T16:53:01+00:00

Ok, This seems straight forward but I am having trouble finding the solution. I

  • 0

Ok,

This seems straight forward but I am having trouble finding the solution.

I have 10 PeopleEditor controls. Each one of the PeopleEditor controls has a CustomValidator and the ControlToValidate property is set to that specific PeopleEditor control. I assign a function to the control based on criteria.

It is possible that the same validation function is assigned to multiple CustomValidators which in turn means the function needs to know which ControlToValidate control it is validating.

Is this clear?

The question is:
How do I reference the control from the ControlToValidate property in the validation function server side c# code?

Here are similar issues but they reference client side or inline validation:
How to get the 'controlToValidate' property on ClientValidationFunction? and
Extract value from control in ControlToValidate property in a CustomValidator control?

UPDATE:
I have 10 of these in the .aspx page:

<asp:Label ID="lblPeople0" runat="server" />
<SharePoint:PeopleEditor ID="edtPeople0" SelectionSet="User,SecGroup" AutoPostBack="false" CausesValidation="false" PlaceButtonsUnderEntityEditor="false" Rows="3" AllowEmpty="true" ValidatorVisible="true" runat="server" MultiSelect="true" MaximumEntities="100" ShowCreateButtonInActiveDirectoryAccountCreationMode="true" />
<asp:CustomValidator id="vldPeople0" display="Dynamic" runat="server" ErrorMessage="Error Message." ControlToValidate="edtPeople0" />

In the .aspx.cs page, I assign the validating function like this:

vldPeople0.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(validate_ThisAndThat);

Then, I have this for the function and need to get the ControlToValidate in order get the ResolvedEntities from it.

/// <summary>
/// Validation function.
/// </summary>
private void validate_ThisAndThat(Object source, ServerValidateEventArgs args)
{
  foreach (PickerEntity entity in (ControlToValidate).ResolvedEntities)
  {
    String tmpPrincipalType = (entity.EntityData["PrincipalType"]).ToString();

    if (tmpPrincipalType == "User")
    {
      if ((entity.EntityData["DisplayName"]).ToString().Contains("aString"))
      {
        args.IsValid = false;
      }
    }
  }
}
  • 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-26T16:53:02+00:00Added an answer on May 26, 2026 at 4:53 pm

    Ok, so the key was to assign an attribute to the CustomValidator…

    <asp:Label ID="lblPeople0" runat="server" />
    <SharePoint:PeopleEditor ID="edtPeople0" SelectionSet="User,SecGroup" AutoPostBack="false" CausesValidation="false" PlaceButtonsUnderEntityEditor="false" Rows="3" AllowEmpty="true" ValidatorVisible="true" runat="server" MultiSelect="true" MaximumEntities="100" ShowCreateButtonInActiveDirectoryAccountCreationMode="true" />
    <asp:CustomValidator id="vldPeople0" display="Dynamic" runat="server" ErrorMessage="Error Message." ControlToValidate="edtPeople0" />
    

    In the .aspx.cs page, I assign the validating function like this:

    vldPeople0.ServerValidate += new System.Web.UI.WebControls.ServerValidateEventHandler(validate_ThisAndThat);
    vldPeople0.Attributes.Add("peopleEditor", "edtPeople0");
    

    Then, I have this for the function.

    private void validate_ThisAndThat(Object source, ServerValidateEventArgs args)
    {
      CustomValidator thisValidator = (CustomValidator) source;
      string strPeopleEditor = (string)thisValidator.Attributes["peopleEditor"];
      PeopleEditor peopleEditor = (PeopleEditor)panel1.FindControl(strPeopleEditor);
    
      foreach (PickerEntity entity in peopleEditor.ResolvedEntities)
      {
        String tmpPrincipalType = (entity.EntityData["PrincipalType"]).ToString();
    
        if (tmpPrincipalType == "User")
        {
          if ((entity.EntityData["DisplayName"]).ToString().Contains("aString"))
          {
            args.IsValid = false;
          }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to the Python world, but this seems very straight forward. Google
This seems like it should be pretty straight forward, but I'm apparently confused. I
I'm having a 'duh' moment where this seems like it should be straight forward,
I'm surprised that I'm having real trouble finding how to do this. It seems
This seems like a straightforward task, but I'm having trouble figuring out the rails
this seems like it should be straightforward, but I'm having trouble getting it to
This seems like a pretty softball question, but I always have a hard time
This seems to be a common problem but I cannot find a solution. I
It seems like this should be straightforward but I'm boggling. I've got my listview
I have this naive regex "<([\s]|[^<])+?>" (excluding the quotation marks). It seems so straightforward

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.