Solved

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

Posted on 2007-11-16
7
3,104 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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

Suggested Solutions

For SharePoint sites, particularly public-facing ones, there are times when adding JavaScript, Meta Tags, CSS Styles or other content to the page <head> section is more practical than modifying master pages.  For instance, you could add the jQuery l…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

19 Experts available now in Live!

Get 1:1 Help Now