Solved

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

Posted on 2007-11-16
7
3,119 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SharePoint Designer 2010 has tools and commands to do everything that can be done with web parts in the browser, and then some – except uploading a web part straight into a page that is edited in SPD. So, can it be done? Scenario For a recent pr…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

772 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