We were using SharePoint:DateTimeControl
in one of our Application Pages in SharePoint. The control returns current date time for SelectedDate if no date is selected.
To check for this we can use IsDateEmpty property.
We were using SharePoint:DateTimeControl
in one of our Application Pages in SharePoint. The control returns current date time for SelectedDate if no date is selected.
To check for this we can use IsDateEmpty property.
Just sharing a sample script that we are using to create a web application and a site collection of type publishing in it.
# SharePoint cmdlets Add-PsSnapin Microsoft.SharePoint.PowerShell</pre> # Set variables $WebAppName = "MyAppPool" $WebAppHostHeader = "servername" $WebAppPort = "portnumber" $url = "http://servername" $WebAppAppPool = "MyAppPool" # This User has to be a Sharepoint Manager Account $WebAppAppPoolAccount = "domain\username" $AuthenticationMethod = "NTLM" $ap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos # Create a new Sharepoint WebApplication New-SPWebApplication -Name $WebAppName -Port $WebAppPort -HostHeader $WebAppHostHeader -URL $url -ApplicationPool $WebAppAppPool -ApplicationPoolAccount (Get-SPManagedAccount $WebAppAppPoolAccount) -AuthenticationMethod $AuthenticationMethod -AuthenticationProvider $ap # Set variables $SiteCollectionName = "MySiteCollection" $SiteCollectionURL = "http://servername:portnumber/" $SiteCollectionTemplate = "BDR#0" $SiteCollectionLanguage = 1033 $SiteCollectionOwner = "LSS\lssspadmin" # Create a new Sharepoint Site Collection New-SPSite -URL $SiteCollectionURL -OwnerAlias $SiteCollectionOwner -Language $SiteCollectionLanguage -Template $SiteCollectionTemplate -Name $SiteCollectionName
Hope it helps ..
Hi,
We were getting the following error that “list doesn’t exist in the site” because the user was not having read permission on that list.
The code we were using was
SPList myList= spWeb.Lists[“mylist”];
A better approach would be
SPList myList = spWeb.Lists.TryGetList(“myList”);
If(myList != null )
// …
Bye ..
Hi,
We were facing issues while creating a new web application through central administration. The user was the farm administrator.
The way we got it fixed was by increasing the set the values for the properties in the Central Admin Sites’ App Pool
Followed by an IISRESET
Hope it helps ..
Hi,
We recently had a requirement to create a web part that would be used to update user profile picture and few other properties.
For this we used the FIileUpload control.
The code used
public void UploadPhoto(string accountName, byte[] image) { string loginNameForProfile = accountName.Substring(accountName.IndexOf(@"|") + 1); if (profileUpload.HasFile) { SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Site.Url)) { SPServiceContext serviceContext = SPServiceContext.GetContext(site); UserProfileManager userProfileMgr = new UserProfileManager(serviceContext); ProfilePropertyManager profilePropMgr = new UserProfileConfigManager(serviceContext).ProfilePropertyManager; // Retrieve all properties for the "UserProfile" profile subtype, // and retrieve the property values for a specific user. ProfileSubtypePropertyManager subtypePropMgr = profilePropMgr.GetProfileSubtypeProperties("UserProfile"); UserProfile userProfile = userProfileMgr.GetUserProfile(loginNameForProfile); SPSite mySite = new SPSite(userProfileMgr.MySiteHostUrl); SPWeb web = mySite.RootWeb; SPFolder subfolderForPictures = web.Folders["User Photos"].SubFolders["Profile Pictures"]; web.AllowUnsafeUpdates = true; Stream fs = profileUpload.PostedFile.InputStream; byte[] buffer = new byte[profileUpload.PostedFile.ContentLength]; fs.Read(buffer, 0, Convert.ToInt32(profileUpload.PostedFile.ContentLength)); fs.Close(); int largeThumbnailSize = 300; int mediumThumbnailSize = 72; int smallThumbnailSize = 48; string accName = accountName.Substring(accountName.IndexOf(@"\") + 1); using (MemoryStream stream = new MemoryStream(buffer)) { using (Bitmap bitmap = new Bitmap(stream, true)) { CreateThumbnail(bitmap, largeThumbnailSize, largeThumbnailSize, subfolderForPictures, accName + "_LThumb.jpg"); CreateThumbnail(bitmap, mediumThumbnailSize, mediumThumbnailSize, subfolderForPictures, accName + "_MThumb.jpg"); CreateThumbnail(bitmap, smallThumbnailSize, smallThumbnailSize, subfolderForPictures, accName + "_SThumb.jpg"); } } string pictureUrl = String.Format("{0}/{1}/{2}_MThumb.jpg", subfolderForPictures.ParentWeb.Site.Url, subfolderForPictures.Url, accName); // Change the value of a single-value user property. userProfile[PropertyConstants.PictureUrl].Value = pictureUrl; imgUserProfile.ImageUrl = pictureUrl; // Save the changes to the server. userProfile.Commit(); web.AllowUnsafeUpdates = false; } }); } } public SPFile CreateThumbnail(Bitmap original, int idealWidth, int idealHeight, SPFolder folder, string fileName) { SPFile file = null; Assembly userProfilesAssembly = typeof(UserProfile).Assembly; Type userProfilePhotosType = userProfilesAssembly.GetType("Microsoft.Office.Server.UserProfiles.UserProfilePhotos"); MethodInfo[] mi_methods = userProfilePhotosType.GetMethods(BindingFlags.NonPublic | BindingFlags.Static); MethodInfo mi_CreateThumbnail = mi_methods[0]; if (mi_CreateThumbnail != null) { file = (SPFile)mi_CreateThumbnail.Invoke(null, new object[] { original, idealWidth, idealHeight, folder, fileName, null }); } return file; } // end of function
The helpful post
Hope it helps
Hi,
We had developed a Visual Web Part for SharePoint 2013 that used IOrganizationService of CRM 2011. It was all working fine however yesterday it started throwing this error.
After some investigation we realized that the user whose credentials we were using as Client Credentials for the OrganizationService had recently been changed.
Updating it to the correct updated one fixed the issue for us.
Hope it helps.