Let's Learn Together!
Most of the examples in the ASP.Net articles section have been taken from ASP.Net and tutorials created by
Scott Mitchell and Marco Bellinaso's
"Real-World Web Development with ASP.NET 2.0". The SharePoint articles have been taken from experience and Inside Microsoft SharePoint 2010 by Ted Pattison, Andrew Connell, Scot Hillier, and David Mann.
Welcome to Jose M. Tamez and his JT Web Net Personal Web Sample Site. This site is for the sole purpose of demonstrating my skills as an ASP.
Net web developer and SharePoint developer, architect and administrator. I wrote all of the code, content and components for this site as well as the design
(not a designer but I've had to do it before and I've also studied web design
and web development), XHTML, CSS (completely table-less)
and I also created the custom web parts on the members page. Everything you see on this site has been created and customized by yours truly.
Actually, this is a full-blown e-Commerce site but I’m not using a payment gateway because they’re not free, fees are too expensive, and I'm not in the business of selling books.
But, in the near future I do have plans to use the Amazon API and begin selling
all of the books I own. I’ve also changed my mind
about the introductions and will use the home page as a SharePoint blog for posting SharePoint related articles
(pending). All of my posts and articles from the Jose M. Tamez blog have been migrated,
categorized and listed under articles. Sign-in as guest and check out the members area and take a look at some of the web parts I've created
(disabled until further notice). You may find at times that it's not working and that's
because I'm constantly working on making it better, or adding more web parts to the page. I will continue to add additional functionality as time permits and I welcome your suggestions and comments.
It's time to start up again and get this site up and running the right way!
First things is first, and thats implementing a captcha ASAP and stop all of the
spam and bots. The next step is to finish my ecommerce portion of the site and
start selling all of the books, videos, and music that I will endorse. Please
allow me some time to get this done but in the mean time continue coming back
and look out for some great learning content. Thanks to all!
I'm often asked this question;
What does it mean when you hear "Strongly Typed Object"? A strongly typed object is one whose schema is rigidly defined at compile time, whereas the opposite, a loosely-typed object, is one whose schema is not known until runtime. With strongly-typed objects you get Intellisense in Visual Studio.
Save a document from extinction! Tag It!
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, and 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 chages. 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.
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