Greetings everyone! I am very excited to annouce that I have been selected to speak at the DevTeach conference that will be held here in Vancouver from June 8-12. I spend a great deal of time blogging about working with the Telerik web controls in my SharePoint development, so I figured this would be a good opportunity to share some of the things I’ve learned and to demonstrate how easy it is to integrate these into your projects.
This is a great conference that promises to be the biggest developer, DBA and ITPro conference in Canada. It’s jam-packed with advanced sessions (level 300 and 400) all on the latest versions of Microsoft products and technologies. I encourage you all to at least check it out and see if some of the other sessions or topics might appeal to you.
Hope to see you there!
I was recently working on a Black Ninja Software project for a client of ours where performance became an issues for one of the custom application pages we had developed. I plan to write up a more detailed report on how I managed to cut the load times of this particular page in half using the ANTS Profiler, but for now I wanted to highlight a piece of the puzzle that I discovered today.
I won’t cover how to load values into a PeopleEditor control from within a SharePoint list, you can view that in more detail here.
Take a look at the example below:
1 2 3 | SPFieldUserValue user = new SPFieldUserValue(web, Convert.ToString(listItem["Employee])); peEmployee.CommaSeparatedAccounts = user.LookupValue; |
If we have an SPFieldUserValue object, calling upon the LookupValue property will return the Name of that user. This is not to be confused with the LoginName property. Assigning that to the CommaSeparatedAccounts property may do the trick and will load that user account into the control but not without a performance hit.
A better approach would be:
1 2 3 | SPFieldUserValue user = new SPFieldUserValue(web, Convert.ToString(listItem["Employee"])); peEmployee.CommaSeparatedAccounts = user.User.LoginName; |
The difference is minor. Instead of using the LookupValue property, we leverage the SPUser object and call upon the LoginName property. In all of my testing, I noticed an improvement in speed when using the LoginName property.
Depending on your environment, the output from either of those properties will differ and that’s the heart of the performance issues. In my environment, LoginName and Name outputted the following:
Name – “Joe User”
LoginName – “domain\juser”
Having the domain specified seems to speed this whole process up. I would be interested to hear from anyone else who’s encountered anything similar.
For each Web Application you create in SharePoint, by default, there is a single Content DB that is assigned to it. Typically, the steps for creating a web application are as follows:
- Launch your Central Administration web site.
- On the Quick Launch bar to the left of the page, click on Application Management.
- Under the SharePoint Web Application Management heading, click on Create or extend Web application.
- Click on Create a new Web Applicaiton.
- The Create New Web Application page requires some information before creating your new web application. I won’t go through all of this in detail, but let’s pay particular attention to the Database Name and Authentication section. I have attempted in the past to alter the database name to match the already existing content db i would like this web application to use. This is not recommended nor does it work consistently. What you’ll want to do is accept all defaults for the database name and proceed with creating your web application. In the next steps we’ll outline how you swap this content db out for the one your already existing content db.
Now once your content db has been created, you’ll need to go back to the Application Management screen. From there, try the following:
- Click on Content databases.
- On the right of the toolbar, look for the Web Application drop down. Make sure you change this to match the web app you’re trying to replace the content db for. I find that sometimes this is defaulted to the Central Admin web application which is not what we want.
- Click on the database name link, this should bring up the Manage Content Database Settings page. Change your Database status to Offline and check Remove content database. Click OK. This content db shouldn’t contain anything since we just created this web application.
- We should now be redirected back to the Manage Content Databases page. Click on Add a content database.
- The only thing you need to change on this page is the Database Name field. Set this to the name of the content db you want to add. Set the search server and click OK.
Now typically this is a smooth operation, however, if you encounter the error below:
Attaching this database requires an upgrade, which could time out the browser session. You must use the STSADM command ‘addcontentdb’ to attach this database.
Open up a command prompt window, and type the following stsadm command in:
stsadm -o addcontentdb -url http://server01/ -databasename WSS_Content
There are other arguments you can use for this command, to see a list of those, type:
stsadm -o addcontentdb
Once the command has completed successfully, try loading your site. If you have any issues at all with this, drop me a line.
Let’s talk about validation and the PeopleEditor control. There doesn’t seem to be a consensus on how this is supposed to be done so I’ll outline my findings and what eventually worked for me.
I’ll start by explaining what I was attempting to do. I have a PeopleEditor control on a custom application page. My custom application page is located in the _layouts directory. On this page, I also have a submit button that saves my data to a SharePoint list upon submit.
Now, I need to ensure before submit, that the PeopleEditor control contains a valid entry. Blank and invalid values are not permitted.
I first attempted to set the AlllowEmpty property to false. However, that didn’t seem to help. If I clicked submit, the page would post back and then the control would display an error once the page reloaded. At this point, it was too late to be informing the user that there was a problem with their entry, the page had already posted back, so this was not useful.
I also tried setting the ValidationEnabled property to true. That didn’t seem to make any difference either. I am confused as to how these two properties are supposed to work.
My next attempt was to add an ASP.NET required field validator to the page as follows:
1 2 3 | <wssawc:PeopleEditor AllowEmpty="false" ValidatorEnabled="true" Width="250px" ID="pePR" runat="server" SelectionSet="User" MultiSelect="false" /> <asp:RequiredFieldValidator ID="rfvPR" ControlToValidate="pePR" runat="server" ErrorMessage="Project Requestor (Cannot be blank)" Text="Cannot be blank." ValidationGroup="SubmitForm" Display="Dynamic"></asp:RequiredFieldValidator> |
This took care of the client side validation that prevented the user from clicking submit without first entering a value into the control.
However, this did not handle the scenario when a user entered an invalid value in the control and hit submit. In this case, the form will attempt to submit and create the item, but will fail to save the value to the list item field because the value was invalid. An example of an invalid value would be bad data in that field.
To fix this, in my submit method, I added an IF statement to check how many resolved entities there were.
1 2 3 4 5 6 | if (pePR.ResolvedEntities.Count > 0) { // continue with the submit } else { // output an error that the user did not enter a valid user } |
If anyone has any feedback, or has had success using the AllowEmpty property, please comment on this post or drop me a note. I’m interested in hearing how others were able to get around this issue.
If you’re building a production SharePoint environment (or even a development one), it’s probably a good idea to get a handle on the best practices for SharePoint databases stored in SQL Server. It will help to understand some key areas before deployment:
- Architecture Recommendations
- Limit content database size to enhance manageability
- Configure autogrowth settings
- Physical Storage Recommendations
- Separate and prioritize your data among disks
- Use multiple data files for large content databases and the SSP search database
- Use multiple data files for content databases
- Use multiple data files for the SSP search database
- SQL Server recommended practices
Blog do Ezequiel wrote a great article that details all of the above. I’ve simply summarized the key points above, but I encourage you to read his post in length. Microsoft has also published some useful resources on this topic (which Ezequiel talks about). I find the following link to be particularly useful:
If anyone has any recommendations for other useful resources pertaining to this topic, please let me know and I’ll include it above and credit your contribution.


