Monthly Archives: March 2009

Good News just became Better

I had posted about 10 percent discount on Microsoft Certification exams. Now you can obtain discount code before 30th April, 2009 and you can sit for the exam (with retake if required) before 31st May, 2009.

If you are still looking for discount code drop me a line immediately. I would also appreciate if you can help me spreading the word by blogging about it :) .

Exploring SharePoint

Products make money, not frameworks. It’s SharePoint time :) . I have worked with SharePoint on POCs but they never got materialized due to license issues. So what’s this beast all about? Keep reading for an overview, with a disclaimer that this information is gathered from numerous resources over a period of time. Hence if there are missing links, omissions or inaccuracies I welcome you to correct them. Also my writing is more from a developer’s perspective.

What’s SharePoint? – A Product built on top of ASP.NET. If you are aware of Master Pages, HttpModules, HttpHandlers, WebParts, Ajax, HttpApplication, Localization, Virtual Directories, ASMX Web Services, HTML, CSS, etc. it’s great, as you would need all of them here.

Why SharePoint? – This is where I was initially stuck and in fact I am still stuck there. At its heart, SharePoint is a site provisioning engine. You can create rich functional personalizable portals / sites using SharePoint within few seconds. These SharePoint portals / sites have a lot of out of box support in terms of templates, lists, features, web services, web parts, etc. Building this out of box support with vanilla ASP.NET can hurt from all aspects. Other usage of SharePoint is in terms of collaboration through Content Management or Business Intelligence. Content Management (primarily around MS-Office) along with Enterprise Search was part of the POC I worked on. SharePoint has support for workflows (read Workflow Foundation) that help automating business processes again with many out-of-box workflows. SharePoint also provides easily scalable and deployable solutions from an administration perspective.

WSS (Windows SharePoint Services) vs. MOSS (Microsoft Office SharePoint Server) – I struggled with this one initially. The closest I got was WSS is the soul of MOSS. Infact MOSS builds on top of WSS providing enterprise features like Search, Excel Services, BDC, etc. But from a development perspective WSS gives a thorough experience which holds good for MOSS too. Also as WSS is bundled with Windows Server license this in a sense makes it free and easy to get started. If you want to get started with SharePoint as a developer WSS should suffice. Latest Version of WSS is called SharePoint Foundation and is available for download from here. Microsoft supports installing Foundation version on Windows 7 / Vista SP2 for development purposes.

Installing WSS – I have been working on TFS / VSTS and installed SharePoint many a times as part of pre-requisites. You can access the document from here. I will proceed ahead with assuming installed WSS 3.0 SP1 on Windows Server 2008.

Drilling into WSS Directory Structures – Once you are done you will see your Default Web Site has a new ‘wss’ directory and a IIS Site ‘SharePoint Central Administration v3’. Below is a snapshot after creating a new Web Application through Administration Site. N.B. each SharePoint Web Application has its own web.config wherein the extensions like ASP.NET modules and handlers are specified. I strongly encourage you to have a look at it.

untitled02

untitled12

As you see in the above snapshot, I have created a SharePoint Web Application (IIS terms it means Web Site with dedicated AppPool) listening on port 9999. You see that this WebApplication in-turn contains 11 folders. Out this 11 folders the 7 ones (which are not underlined) are present inside ‘wss – 9999’ directory of Default Web Site. As you would have guess these 7 folders map to “D:\inetpub\wwwroot\wss\VirtualDirectories” folder. If you add a new Web Application there would be an addition of a new folder which is the port number where that Web Application is listening. Coming to remaining 4 folders they appear to be shared across all Web Applications including Central Administration Site. These folders are located in 12 Hive folder “D:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12”. Let me elaborate on purpose of last 4 folders:
_controltemplates – Contains ASP.NET user controls (*.ascx)
_layouts – Contains non customizable .ASPX & .MASTER pages
_vti_bin – Contains ASMX Web Services & standard DLLs like Microsoft.SharePoint.
_wpresources – primarily used to store resources of WebParts.

In SharePoint terminology pages located in above directories are called ‘Application pages’ residing on physical file system. Apart from these shared folders remaining content for Web Application is maintained inside a SQL SERVER DB. In fact for every Web Application you will create SharePoint will also create a content database for you. Pages stored in content database are called ‘Content pages’ or ‘Site pages’. Along with content database there is also a configuration database for the farm as shown below.

untitled2

What are developer opportunities with SharePoint? – Plenty. Creating features, templates, custom lists, document libraries, event receivers, workflows, web parts, application pages, solution packages, etc. There are couple of additional APIs namely WSS Object Model & CAML (Collaborative application markup language) which developers need to learn for being more effective. To edit site pages one can take help of SharePoint Designer & also there are developer extensions available to VS.NET 2008 to boost productivity for Sharepoint development.

These might look like random thoughts, but these are the ones I was looking for to getting started with SharePoint. I hope to share more with you in coming days.

Are you working on any of these?

I bumped into this today. It is Gartner’s Identification of Top 10 Strategic Technologies for 2009. I have been touched by few of them but certainly not drilled into. Hopefully I should see some action on this front in upcoming quarter. Between, do you find Gartner identifications relevant or there are missing links?

10% Discount on Microsoft Certification exams with a free retake before 31st March, 2009

Good news!!! Microsoft is providing MVPs with free discount vouchers for benefit of local communities. If you are preparing for any Microsoft certification exams or know somebody who is planning to take one, do drop in a line to me. I will ensure that the examination discount voucher reaches you ASAP. Let’s spread the word to save some hard earned money of our friends, especially during these bad times.

Note that the Exam discount Voucher Code is valid for exams taken by May 31, 2009 in India. Also the limited time offer is valid for Microsoft Certified Technology Specialist (MCTS), Microsoft Certified IT Professional (MCITP) and Microsoft Certified Professional Developer (MCPD) exams only. Go to this link for more information to assist you on Microsoft Certification exams. To schedule an exam after getting voucher code, go to this URL to find a testing center near you.

Please ensure that you verify discounts at your end, to avoid any surprises (no liabilities, please). If you have any queries I will more than happy to take it up with my lead. Till next time, keep learning :) .

ControlTemplate vs. DataTemplate vs. HierarchicalDataTemplate vs. ItemsPanelTemplate

If you don’t know what they are, then you need to go here first. 

Before we get into differences between them, let me show how one would typically use them. It’s a good practice that all your templates are embedded inside resources / styles. It makes your XAML centralized, shareable and easier to understand (a re factored XAML of sorts, waiting for ReSharper to include this refactoring :) ).

Don’t Do:
<ListBox>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <!– Your Data Template Goes here–>
                </DataTemplate>
            </ListBox.ItemTemplate>
</ListBox>

Recommended:
<Window.Resources>
        <DataTemplate x:Key=”myDataTemplate”>
            <!– Your Data Template Goes here–>            
        </DataTemplate>
</Window.Resources>

<ListBox ItemTemplate=”{StaticResource myDataTemplate}” />

The above XAML holds true also for HierarchicalDataTemplate & ItemsPanelTemplate. But it won’t quite work for ControlTemplate, as ControlTemplate can be assigned to Template property of a class that inherits from ContentControl class, which ListBox doesn’t.

So the listbox code would typically look like this:

<ControlTemplate x:Key=”myControlTemplate” TargetType=”{x:Type ListBoxItem}”>
            <TextBox />
</ControlTemplate>

<ListBox>
            <ListBoxItem Template=”{StaticResource myControlTemplate}” />            
</ListBox>

But the problem with above snippet is, you are manually specifying item which is never the case in real world. Ideally you would like to bind ItemsSource Property of ListBox with some collection obtained at runtime from your data access layer. Solution to this problem is creating a style and binding it to ItemContainerStyle property of ListBox. By doing that you will be able to use ItemsSource for Binding & the ControlTemplate which is present inside the style will be applied to each binded item.

<ListBox x:Name=”myList” ItemsSource=”{Binding}” ItemContainerStyle=”{StaticResource myStyle}” />
<Style x:Key=”myStyle” TargetType=”{x:Type ListBoxItem}”>
            <Setter Property=”Template”>
                <Setter.Value>
                    <ControlTemplate TargetType=”{x:Type ListBoxItem}”>
                        <TextBox Text=”{Binding collectionPropertyName}” />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
</Style>

ItemsPanelTemplate is mainly used by controls inheriting from ItemsControl class for displaying their Items. ItemsPanelTemplate can be customized through ItemsPanel property of ItemsControl class or any class which inherits from ItemsControl.

<ListBox x:Name=”myList” ItemsPanel=”{StaticResource myItemsPanelTemplate}” />
<ItemsPanelTemplate x:Key=”myItemsPanelTemplate”>            
            <StackPanel Orientation=”Horizontal” />
</ItemsPanelTemplate>

The point of confusion is normally between selecting a ControlTemplate or DataTemplate. Normal saying goes as DataTemplate provides visualization to a business object while ControlTemplate does the same to a UI control. But in my project I see ControlTemplate used almost everywhere. Normally UI guys start creating screens while we are still giving shapes to our domain model (deadlines issues you see). Moreover, I feel one has to get slightly deep with WPF control properties to create an appealing professional UI.  So atleast here, we developers don’t quite mind giving a free hand to UI guys. We just go over to control templates residing inside styles & giving names of Business Object properties inside the bindings created by them. Also ControlTemplate triggers are based on UI control properties which is what UI team is often interested in. Few more differences are given here.

HierarchicalDataTemplate is an extension of DataTemplate with an additional ItemSource property. It is used to render hierarchical data in controls like treeview or menu. HierarchicalDataTemplate ends with a Data Template.

<HierarchicalDataTemplate DataType=”{x:Type Department}” ItemsSource=”{Binding Path=Classes}”>
            <TextBlock Text=”{Binding Path=DepartmentName}” />
</HierarchicalDataTemplate>

<DataTemplate DataType=”{x:Type UniversityClass}”>
            <TextBlock Text=”{Binding Path=ClassName}” />
</DataTemplate>

Hope the above helps you in getting started with WPF templates.

Follow

Get every new post delivered to your Inbox.

Join 80 other followers