Let's Learn Together!
Welcome to Jose M. Tamez and his professional portfolio. This site is for the sole purpose of demonstrating my skills as an ASP. Net web developer. The web site I've created and used for CTU can be found here. My web site portfolio will be updated after the first of the year. The entire site will have a new look & feel and I'll be moving to ASP.Net MVC.
Update: I've been looking for a really cool look and feel but I haven't found anything I've liked and would be happy with so I'm still looking.
Save a document from extinction! Tag It!
Mouseover one of the titles below
Custom Branding Solution
So your client would like for you to provide a custom branded master page and would also like it delivered as a feature at the site collection level. No Problem!
Before developing the solution you need to create the new master page. That means you need to fire-up SharePoint Designer 2010 and go through the
process of creating a custom branded master page along with the files and folders required. How do you do that? Well, make a copy of the v4.master and rename
it to a name of your choice. In my case, I named it jtwebnet.master like you see here. You can do this with either a Team Site template or the one
I used for my Site Collection (root), the Publishing template.
Then, under the Style Library I created a folder called "jtwebnet" and under
jtwebnet another folder called "images". I also created a new CSS styles sheet
called "jtwebnet.css" under the jtwebnet folder. Here is a screenshot:
Work your magic on your development environment and make the adjustments and tweaks required. When your happy with the final look create a folder on your desktop
and save the master page, images, and CSS file. I did it this way but you can choose to do it differently so long as you have access to those files when it comes time
to adding them to your solution.
Oh, about that solution. Now lets fire-up Visual Studio 2010 and create a new project,
using the "Empty SharePoint Project" template. I named my project "jtwebnetBrandSolution"
You can point the project to the sandbox or the farm and you can create this
solution in either SharePoint Foundation or SharePoint Server. It will work
either way because you are deploying all the required branding files using template files and Modules
and the solution is not picking up any server dependencies. Take a look at the
folder structure of solution.
Double click main.feature and make the following changes. Scope to Site!
Double click the Main.EventReceiver.cs file and add the following event handlers.
Remember Syncronous/Asyncronous? Syncronous provides a blocking action to a
running thread and only continues when an another action completes. Asyncronous
provides action after-the-fact using another thread (two threads) for a method,
or somethig like that. Ok, I'm getting off track and I'm sure I'll get mail on
Now let's add two Modules shall we, I named them "MasterPageGallery" and the other one "Style Library". Right-click the MasterPageGallery folder and add existing file and add the master page
(remember where you saved your files?)
Open the elements.xml file and add the following markup. You must add the following attributes and properties in order to correctly deploy the master page.
This is the SharePoint beast! You want to know the difference between typical
ASP.Net web developing and SharePoint? Well, aside from all of the many differnt
methodologies and the difficulty in debugging your solutions, you need to learn
Collaborative Application Markup Language (CAML).
We don't have to modify the elements.xml file under the Style Library Module so you can just add the existing files such
as the .CSS file and images. Yes, right click the Style Library and add the .CSS
file and right click the images folder and add existing files, IMAGES!
Deploy the solution and then navigate to the home page.
After Solution Deployment
Now go to site actions and click site settings. Under Site Administration click Site Collection Features and deactivate the feature.
Now you can deploy this solution to any farm and better yet, an easier way to migrate your solution to the next version, we hope, right?
References: Microsoft SharePoint 2010 by Ted Pattison, Andrew Connell,
Scot Hillier and David Man (Mar 8, 2011)
Custom Site Provisioning Provider
Creating custom site definitions are now a thing of the past. Microsoft now recommends using the
component "Site Provisioning Provider" as best practice for providing a custom
site template. This is not new and was also available WSS3.0 but instead of
creating a custom site definition, we add custom provsioning code to the
out-of-the-box site template.
Fire up Visual Studio 2010 and
create new project using the "Empty SharePoint Project".
Before you start working on
your new project, open the properties page and on the "Application" tab, make
sure that the target framework is set to ".Net Framework 3.5". SharePoint 2010
is not using .Net Framework 4.0.
Then select the "Build" tab
and by default the platform target will be set to "Any CPU". Change this to x64.
Just do it!
Right click the solution name
and choose "Add" and right click "SharePoint Mapped Folder". We want to map the
SharePoint root so click the very top "SharePointRoot" The solution explorer
should now like this:
Now add the following folder
structure underneath your sharepoint root like this:
Next, add an XML file
underneath the XML folder like so:
The XML will contain the
following provisioning instructions and it will look like this:
Next, add a Class file and
give it a name. This is your "Provisioning Provider". Add the
Microsoft.SharePoint referrence and if you're a newbie, you'll
find it underneath the "ISAPI" folder underneath the SharePoint "Root".
What was it called in MOSS2007? The 12 Hives folder, but for SharePoint
2010 it's now called the "SharePoint Root". In Ted Pattison's
"The Great SharePoint Adventure 2010"
development training course, we were told that the new SharePoint product team changed
it to "SharePoint Root". Nonetheless, I've noticed that some are referring to it
as the 14 hives.
Also make sure the Microsoft.SharePoint.Security referrence is also added. Build
your project here. Or you can wait until you've added the code. I've gotten into
the habbit of buidling my projects often, even for SharePoint.
Look at the top line. You are inheriting from the
SPWebProvisioningProvider base class and overriding virtual methods to create your own Site Template Provisioning Provider.
You're actually overriding the
"Provision" method of the Provisioning Provider base class. When you implement
this virutal method, you can now specify custom configuraton properties by calling the
"ApplyWebTemplate" method. This makes it possible to customize out-of-the-box
site templates with our own customized provisioning instructions. Very cool!
During the execution of code,
the out-of-the-box site template is created through the "ApplyWebTemplate"
method using the "Blank Site" template "STS#1". The rest of the code is added to
provide the required site elements for the custom site template.
Again, build your solution. Then deploy it like this:
After deploying your solution
and no errors are reported, you can check your new category and templates using
several different ways. First, if you have "Self-Service Site Creation" enabled,
and I hope you don't, you can click the link "Self-Service Site Creation" under
"Annoucements" on the home page.
Then click the "http://your site/_layouts/scsignup.aspx" link and you will navigate to the following page.
As you can see, the category "JTWebNet" is listed, and underneath this category
are the "JTWebNet Standard Team Site" and "JTWebNet Consultant Site" templates.
You don't see an image for either template because I haven't added one to the
layouts/images/jtwebnet/ folder. I chose the "JTWebNet Consultant Site" template
for my first custom templated site. After SharePoint provisions the site by default your taken to the SharePoint security groups setup page where you specify which Active Directory groups are to be used.
As you can see the site owner/administrator is already plugged into both the member/contributors and admin groups. After you setup your SharePoint security groups you are now ready to start customizing
your new site with web parts and content.
Very easy to implement and
provides a professional looking custom site template for your client. Now you
can take it a step further by deleting the other categories thereby eliminating
the option for creating out-of-the-box site templates. Go
to site settings and click on the "page layouts and site templates" link and set
If the site owner/administrator decides to create a subsite, there is only one category
diplayed and only those custom template options will be available. For the farm
administrator that is a different story. Although I may have always provided that
customization with a custom site definition, I will not show you how to delete
those categories with this solution.
Before I move on to feature stapling, I think I will post the branding solution first.
It's very easy to customize the Server Ribbon using a Feature custom action and ribbon XML.
Follow these steps to get you going:
Fire up Visual Studio and on the File menu point to New, and then click Project.
In Project Types, under C#, select "Empty SharePoint Project". Type UnserInterfaceActions as the project name, Click OK
In the SharePoint Customization Wizard, select Deploy as a sandbox solution. Click Finish.
In Solution Explorer, right-click the UserInterfaceActions project, select Add, and then select New Item.
In the Add New Item dialog box, select the Empty Element template. Enter UserInterfaceActions as the Name.
Open the Elements.xml file and add the following xml markup.
This is the final solution!
This is very simple but demonstrates how you can modify the Server Ribbon and add custom
actions. To learn more about the Server Ribbon in SharePoint Foundation click
I forgot to add the
code for the "FeatureDeactivating" event handler in the event receiver. If you
don't add a Event Receiver with this event handler, the template files will remain in the web part gallery. Unless
you enjoy doing extra work, the feature deactivating event can do it automatically when you deactivate the