Sharepoint creator type, read and set with controls

Source: Internet
Author: User

Sharepoint Study Notes

Http://blog.csdn.net/qq873113580/article/details/20390149

Human Control

Determine whether the information is filled

Function sub ()
{
Var TLID = "<% = peProjectTL. ClientID %>" + "_ downlevelTextBox ";
Var peProjectTL = document. getElementById (TLID). value;
If (peProjectTL = ""){
Alert ("Set Project Authorizer ");
Return false;
}
Return true;
}

Set the value for the person control in the background

Int proid = Convert. ToInt32 (Request. QueryString ["proid"]);
Using (SPWeb = new SPSite (RootUrl). OpenWeb ())
{
SPList projectSpList = web. GetList (RootUrl + "/Lists/ProjectList/AllItems. aspx ");
SPListItem item = projectSpList. GetItemById (proid );
If (item ["Authorizer"]! = Null)
{
SPFieldUserValueCollection spFieldAssignedToCollection = item ["Authorizer"] as SPFieldUserValueCollection;
String assignedTologinName = string. Empty;
For (int I = 0; I <spFieldAssignedToCollection. Count; I ++)
{
SPFieldUserValue userassignedToValue = spFieldAssignedToCollection [I];
If (I = spFieldAssignedToCollection. Count-1)
{
AssignedTologinName + = userassignedToValue. User. LoginName;
}
Else
{
AssignedTologinName + = userassignedToValue. User. LoginName + ",";
}
}
PeProjectTL. CommaSeparatedAccounts = assignedTologinName;
}
}

Obtain the background value

Var assignedToColl = new SPFieldUserValueCollection ();
ArrayList list = leleeditorassignedto. ResolvedEntities;
SPWeb spassignedto = spWeb;
AssignedToColl. AddRange (from PickerEntity p in list
Select spWeb. EnsureUser (p. Key)
Into assignedTo
Where true
Select new SPFieldUserValue (spWeb, assignedTo. ID, assignedTo. LoginName ));
If (assignedToColl. Count! = 0)
{
Item ["AssignedTo"] = assignedToColl;
}
Else
{
Item ["AssignedTo"] = null;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.