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;
}