Solved

How do I tell if the Sharepoint PeopleEditor control is blank or valid

Posted on 2007-11-16
7
3,083 Views
Last Modified: 2010-04-21
Hello All -
I'm using C#.

I'm using the PeopleEditor control from Sharepoint. On a button submit, I'm trying to see if PeopleEditor is blank and if it is a valid name .

Thanks for any help in advance.


//Here is my code

//In my aspx file:

<SharePoint:PeopleEditor id="peopleEditor" runat="server" IsValid="true" AllowEmpty="false" Height="20px" Width="200px" BackColor="Cornsilk" AllowTypeIn="true" MultiSelect="false"></SharePoint:PeopleEditor>

//In the aspx.cs file

Microsoft.SharePoint.WebControls.PeopleEditor PE1 = (PeopleEditor)Form.Controls[i].FindControl("peopleEditor");

if (PE1. ) // I need to find out if PE1 is blank and/or Invalid //

{

    ErrorMsg.msg = ErrorMsg.msg + "Contact Name " + @"\n";

    valRO_CN.Visible = true;

}

else

{

    valRO_CN.Visible = false;

}

Open in new window

0
Comment
Question by:JordanBlackler
  • 5
  • 2
7 Comments
 

Author Comment

by:JordanBlackler
ID: 20301746
After messing around, this code works, but there has to be something else that makes more sense.
if the name is InValid or blank the lengh equals zero.
Int32 intLength = PE1.CommaSeparatedAccounts.Length;

            if (intLength == 0) 

            {
 

                ErrorMsg.msg = ErrorMsg.msg + "Contact Name (Requesting Office)" + @"\n";

                valRO_CN.Visible = true;

            }

            else

            {

                valRO_CN.Visible = false;

            }

Open in new window

0
 

Author Comment

by:JordanBlackler
ID: 20301783
I also need to know what the value is,
0
 
LVL 15

Accepted Solution

by:
liebrand earned 500 total points
ID: 20301820
Try this...
ArrayList entities = PE1.ResolvedEntities;

foreach (object entity in entities)

{

   PickerEntity pickerEntity = (PickerEntity)entity;

   string accountName = pickerEntity.Key;

   string displayName = pickerEntity.DisplayText;

   // pickerEntity.EntityDate[] has other values like first name, last name, etc you might be interested in.

}

Open in new window

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:JordanBlackler
ID: 20301868
Thats great, thanks a lot.
Do you where can i find information on this. I looked all over the web and i couldn't find a thing.
0
 
LVL 15

Expert Comment

by:liebrand
ID: 20301890
Unfortunately not -- I kind of had to figure that out on my own using things like the debugger.  However, I try to update the community pages on MSDN as much as I can (http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.entityeditor.updateentities.aspx -- see community edit below) when I find out how to do something that is not documented very well.

I'll try to get around to do it for this question as well.
0
 

Author Closing Comment

by:JordanBlackler
ID: 31409660
Thanks
0
 

Author Comment

by:JordanBlackler
ID: 20301907
thanks for the help
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now