Friday, September 17, 2010

Structure Hierarchy of the SharePoint 2010

Farm – The base of the SharePoint tree applications, servers, the installation itself.

–> Web Applications – Central Administration is a web app. Each web application has a web.config like any other ASP.net web app, includes databases, dlls, code, virtual directories, a content database, etc. – content databases are managed from Central Administration > Application Management.

—–> Content Database – contains all documents, Site Pages (.aspx) and content within a SharePoint web application. A SharePoint app can have more than one content database. Has one or more Site Collections, which are the smallest entity you can put in a content database. For important site collections, you may want to have each with a separate content database & server.

———-> Site Collections – Can be created in Central Administration > Application Management > create new site collection. To add a site collection to a specific database, you need to use the SharePoint object model or PowerShell. You can add a site collection in any app from Central Administration. Site collections can be individually customized in Site Settings > Site Collection Features and with SharePoint Designer, custom code, etc. You can assign Quota Templates to manage size allocation, etc. You can set the specific URL of the Site Collection upon creation, however it will begin with the name of the web app followed by a dropdown. To add paths to the dropdown, go to Central Administration > Application Management > Manage Web Applications(see Add a Managed Path to a Web Application in SharePoint 2010). By default, a root Site container is added to each Site Collection when it is created in Central Administration, but you must actually create the top-level site (the first site you create). Site Collections exist independently of one another, and can be moved in and out of Web Applications without affecting other Site Collections. They do not inherit attributes from root or top-level site collections, such as users and permissions: This is one of the most important features of SharePoint – security and permissions.
Ex. http://testwebapplication/testnewmanagedpath/testsitecollection

———————–>Various Sites – Each Site Collection has at least one top-level Site created automatically.

——————————>Lists & Libraries – the meat of your SharePoint site where content and data is managed.

Thursday, September 16, 2010

Sharepoint Casceding DropDown

The request for Cascading Drop Down, filtered drop down, dependent drop down or what you call them is one of the most common requirements from customers. This rather basic functionality is surprisingly not implemented in either WSS 3.0 or MOSS 2007.

What is Cascading Drop Down?
You have two columns in your SharePoint list, Country and City. Both are lookup/drop down columns. When you choose a country in the Country Drop Down, you only want to see the cities in this country available in the City Drop Down column. This of course makes life easier for the end user, and improves data quality.

The solution
Instead, I have used this solution with success. The list is still standard SharePoint, which gives great flexibility and stability. This way, the filtering is done in the forms for creating and editing elements. Because of this, you don’t even have access to the server to implement this. I have used this solution both in document libraries and in regular SharePoint lists.

1. Add the Jacascript
Download the Jquery file jquery-1.3.2.min.js by Jquery.com. Download jquery.SPServices-0.4.8.zip from the Jquery Library for SharePoint Codeplex site (newer version is probably also OK). Upload jquery-1.3.2.min.js and jquery.SPServices-0.4.8.min.js (from the zip file) to a document library that everyone accessing your site has access to (a library on the top level site can be wise).

2. Create your relationship lists
Make two lists, one for the parent Country and one for the Child :
                              (Country)                                       (City)

The Country column can be a look up from the Countries list, but you can just as well use a standard single line of text column. This can theoretically give better performance, but you must of course be precise when filling out the County column so that the values here matches the ones in the Countries list.

3. Create the list using the Drop Down
                                             Vacation Plans list:

This is the list where I want my Cascading Drop Downs. Country and City are lookup columns against Countries and Cities lists. The lookups goes against the title field in the respective columns.

4. Make the magic happen
In SharePoint Designer, create your own NewForm.aspx (or EditForm.aspx, you’ll need both if you want it to work when editing items).If you don’t know how to do this, I’ll probably post a tutorial later. Tip: don’t edit the existing forms, but copy them and assign them as default forms.

Just below

insert this code:
NOTE: For this you have to move into Advanced Mode of the page in Page code view side in sharepoint designer.


Save and create a new item using your new form:

Wednesday, September 15, 2010

Custom Search WebPart for Sharepoint 2010

 In SharePoint 2010, you can use the query object model to build custom search
Web Parts and search applications. This object model allows you to query against SharePoint Server search as well as to FAST Search Server 2010 for SharePoint.

The FullTextSqlQuery class available in the object model allows you to build complex search queries based on SQL syntax however, the KeywordQuery class can be used to issue search queries based on simple query syntax. With Fast Search Server 2010, this class can also be used to run queries based on the Fast Query Language (FQL), which supports advanced queries in enterprise environments.

The example below demonstrates using the query object model to issue a search query based on a keyword search with the KeywordQuery class. This example is built as an application page with a text input field called txtSearch, a button for submitting the query called btnSearch, and an SPGridView called searchGrid.

Please Note : Before you can run search queries, you also need to specify the search server that should be used for indexing in Central Administration, under Application Management -> Databases -> Manage Content Databases -> [Your content DB] > Search Server.

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Data;
using Microsoft.Office.Server;
using Microsoft.Office.Server.Search;
using Microsoft.Office.Server.Search.Query;

namespace Apress.SP2010.Layouts.CustomSearch
{
public partial class ApplicationPage1 : LayoutsPageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SetGridColumns();
}
}

// The event is called when the search button is pressed
protected void btnSearch_Click(object sender, EventArgs e)
{
DataTable search = new DataTable();

using (SPSite site = new SPSite(SPContext.Current.Web.Site.Url))
{
KeywordQuery query = new KeywordQuery(site);

query.ResultsProvider = Microsoft.Office.Server.Search.Query.

SearchProvider.Default;

query.ResultTypes = ResultType.RelevantResults;

query.KeywordInclusion = KeywordInclusion.AllKeywords;

query.QueryText = txtSearch.Text;

ResultTableCollection results = query.Execute();

if (results.Count > 0)
{

ResultTable relevant = results[ResultType.RelevantResults];

search.Load(relevant);

DataView view = new DataView(search);

// Fill the SPGridView defined in the page markup

searchGrid.DataSource = search;

searchGrid.DataBind();
}}}

private void SetGridColumns()
{
SPBoundField fieldTitle = new SPBoundField();

fieldTitle.HeaderText = "Title";

fieldTitle.DataField = "Title";

SearchGrid.Columns.Add(fieldTitle);

SPBoundField fieldPath = new SPBoundField();

fieldPath.HeaderText = "Path";

fieldPath.DataField = "Path";

SearchGrid.Columns.Add(fieldPath);

SPBoundField fieldAuthor = new SPBoundField();

fieldAuthor.HeaderText = "Edited";

fieldAuthor.DataField = "Write";

SearchGrid.Columns.Add(fieldAuthor);
}}}

In the above code, the OnClick handler for the button creates a KeywordQuery object and passes the text from the text field to the QueryText property. After calling Execute, the results are available through the ResultTable at the index ResultType.RelevantResults in the returned ResultTableCollection. Using a DataTable, these results are bound to the SearchGrid for display. The relevant table columns are bound using the SetGridColumns method during Page_Load.

Tuesday, September 14, 2010

Combining VS 2008 and VS 2010

This article discusses about how programmers can upgrade to Visua Studio 2010 while the remaining team members on the current project are still using Visual Studio 2008. This document also explains the approach w.r.t to c# and vb.net.

Combining VS 2008 and VS 2010

Programmers can upgrade to VS2010 while the remaining team members on the current project are still using VS in 2008. But in order to do so you need to know a few tricks such as the LangVersion flag.

Step 1:

To begin with a secured copy of the current solution file must be made. This is very important because solution files are not backwards compatible [Note: Project files are backward compatible] Once the copy is created you can perform the usual solution upgrade as if you were permanently moving to a new version of Visual Studio.

Step 2:

Now we need to make sure that the upgrade process should not collapse to the Visual Studio 08 solution. Under the tests we have run so far the only negative effect was a couple of warnings emitted during the build process.

Step 3:

We need to proceed using the VisualStudio.NET 2.0 series of libraries, but the target framework settings are enough to account for that. The notable part is to avoid using any new language features from VB 10 or C# 4. This is where the langversion flag comes into the picture. This flag restricts the compiler to a specific version of the language. For C# that means the 2003 ISO specification, the 2006 ISO specification, or C# 3.0. In Visual Basic you can choose between Visual Basic 9 and Visual Basic 10.

Step 4:

Now, we need to set LangVersion flag as below:

<PropertyGroup><LanguageVersion>2</LanguageVersion></PropertyGroup>

For C#.net, we can get this feature in Advanced Menu > Build Tab

Note: These instructions are mainly for class libraries, console, and Windows applications. ASP.NET projects have their own flukes and may additional issues not addressed here.

Thursday, September 9, 2010

What is WCF?

WCF is a .NET platform for developing services .Service is any functionality that can be consumed by the outside world. A service defines well defined communication protocols to communicate with it.
A service can be located anywhere , it could be on local machine on the intranet or even internet.A client consumes the functionality exposed by the service.A service can be anything it can be an independent application like asp.net or it can be another service.
Client and Service communicate with each other by sending messages.
 
SOAP Message SOAP Message
Client HTTP/TCP /MSMQ HTTP/TCP/MSMQ Server







Since the functionality of the service is hidden to the outside world. Service exposes metadata that client uses to communicate with the service. Metadata can be in any technology neutral format like wsdl.
Client always uses proxy to communicate with the service irrespective of where service is located. In WCF every service has endpoints and the client uses theses endpoints to communicate with the service.
Every endpoint has three important pieces of information.
Address , Binding and Contract.
Address specifies the location of the service.
Binding specifies how to communicate with the service(protocol).
Contract specifies what the service does.

A typical endpoint in the configuration file appears as :
<endpoint address = "http://localhost/TestService/" binding="wsHttpBinding"
contract = "MyNamespace.IContract"/>

WCF has four types of contracts
  1. Service Contract: Describes the operations of the service
  2. Data Contract: Define the data types passed to and from the service

  3. Fault Contract: Define the erros raised by the service

  4. Message Contract: Allows the service to interact directly by using the message.
Basic WCF service

System.ServiceModel.dll is the main assembly for WCF services. To create a WCF service we need to apply the service contract attribute either on the interface or the class.

namespace WcfService1
{
     [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string HelloWorld();

    }
    public class Service1 : IService1
    {      
          public string HelloWorld()
            {
                return "Hello WCF";
            }
      }
}


We can also use explicit interface implementation like this :

         string IService1.HelloWorld()
            {
                return "Hello WCF";
            }


Note when using explicit interface implementation we can't use the public access modifier.

Method Overloading
 
To use method overloading we need to use the name attribute of the OperationContract attribute.

If we write the following implementation for method overloading it will throw an exception at service host load time.

        [OperationContract]
        string HelloWorld();

        [OperationContract]
        string HelloWorld(string Message);


To use method overloading in WCF service we need to use the Name attribute of the OperationContract attribute.

        [OperationContract(Name="HelloWorld")]
        string HelloWorld();

        [OperationContract(Name = "HellowWorldMssg")]
        string HelloWorld(string Message);


In the later articles we will see how to host the service and call it using the client application.

Data Contracts

We can pass only the primitive datatypes to OperationContracts .If we want to pass custom data types to OperationContracts we need to use the DataContract Attribute on the Custom datatype.

    [DataContract]
    class Customer
    {
        int name;
        [DataMember]
        public int Name
        {
            get { return name; }
            set { name = value; }
        }
        int address;
        [DataMember]
        public int Address
        {
            get { return address; }
            set { address = value; }
        }
    }

Monday, September 6, 2010

What is Windows Azure ?

Windows Azure™ is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft® data centers.

Windows Azure is a flexible platform that supports multiple languages and integrates with your existing on-premises environment. To build applications and services on Windows Azure, developers can use their existing Microsoft Visual Studio® expertise. In addition, Windows Azure supports popular standards and protocols including SOAP, REST, XML, and PHP.
What is Windows Azure?Windows Azure promo
Use Windows Azure to:

* Run enterprise workloads in the cloud
* Build, modify, and distribute scalable applications with minimal on-premises resources
* Perform large-volume storage, batch processing, intense or large-volume computations
* Create, test, debug, and distribute Web services quickly and inexpensively

Windows Azure Benefits

* Bring your ideas to market faster and pay as you go
* Reduce costs of building and extending on-premises resources
* Reduce the effort and costs of IT management
* Respond quickly to changes in your business and customer needs
* Choose an on-premises or off-premises deployment model that best suits your needs.
* Scale your IT resources up and down based on your needs.
* Consume computing resources ONLY when the needs arise.
* Focus less energy on managing operational resources and constraints.
* Remove the need to manage hardware
* Use your existing development skills to build cloud applications
* Consistent development and management experience across on-premises and the cloud.

Customer Success Stories with Windows Azure
Windows Azure Features

Learn more about Windows Azure on MSDN

Computation

* Ability to run Microsoft ASP.NET Web applications or .NET code in the cloud
* Service hosting environment that includes Internet Information Services 7.0 and Microsoft .NET Framework 3.5 SP1, Microsoft .NET Framework 4.0
* Security supported by flexible Code Access Security policies
* Small runtime API that supports logging and local scratch storage
* Web portal that helps you deploy, scale, and upgrade your services quickly and easily
* FastCGI support allows customers to deploy and run web applications written with non-Microsoft programming languages such as PHP
* .NET Full Trust to allow usage of additional .NET features such as Windows Communication Foundation (WCF).
* From Full Trust .NET, developers can call into unmanaged DLLs

Simple Data Storage

* Blobs, tables, and queues hosted in the cloud, close to your computation
* Authenticated access and triple replication to help keep your data safe
* Easy access to data with simple REST interfaces, available remotely and from the data center

Sharepoint out of the box web parts


Here is a list of Web Parts that are out of the Box I have listed the new or enhanced SharePoint 2010 Web Parts in Bold font with descriptions
*******NOTE: THE FUNCTIONALITY LISTED BELOW IS BASED ON THE BETA IMAGE AND CERTAIN FEATURES MAY NOT MAKE THE FINAL RTM PRODUCT.  I AM ALSO SHOWING ALL FUNCTIONALITY INCLUDING ENTERPRISE SHAREPOINT 2010 WEB PARTS THAT MAY NOT BE AVAILABLE ON STANDRD OR FOUNDATION VERSION OF THE PRODUCT.*******
Lists and Libraries - These are similar to the same Web Parts offered in MOSS 2007.
- Announcements
- Calendar
- Contacts
- Links
- Shared Documents
- Sites Assets - Use this library to store files which are included on page within the site such as images on Wiki pages 
- Tasks
- Team Discussions
Business Data
- Business Data Actions
- Business Data Connectivity Filter
- Business Data Item
- Business Data Item Builder
- Business Data List
- Business Data Related List
- Indicator Details
-Status List
Content Rollup
- Content Query
- HTML Form Web Part
- Picture Library Slideshow Web Part
- RSS Viewer
- Web Analytics Web Part - Displays the most viewed content, most popular search queries, or most popular clicked search results as reported by Web Analytics for the site or site collection
- XML Viewer
Documents
- Document Set Contents - Displays the contents of the Document Set
- Document Set Properties - Displays the properties of the Document Set
- Enter a Document ID - Finds a document by its Document ID
- Relevant Documents - Displays documents that are relevent to the current user
Filters
- Choice Filter
- Current User Filter
- Date Filter
- Filter Actions
- Page Field Filter
- Query String (URL) Filter
- SharePoint List Filter
- SQL Server Analysis Services Filter
- Text Filter
Media and Content
- Content Editor
- Image Viewer
- Media Web Part - Use to embed media clips (video and audio) in web page
-
Page Viewer
- Silverlight Web Part - A Web Part to display a Silverlight application
My Information
- My Calendar
- My Contacts
- My Inbox
- My Mail Folder
- My Tasks
Navigation
- Categories
- Site Aggregator
- Sites in Category
- Summary Links
- Table of Contents
- Tag Cloud - Displays the most popular subjects being tagged inside your organization
Office Client Applications
- Excel Web Access
- InfoPath Form Web Part - Use this Web Part to display an InfoPath browser-enabled    form
- Visio Web Access - Enables viewing and refreshing of published Visio Diagrams
-
WSRP Viewer
People
- Contact Detail
- Note Board - Enables users to leave short, publicly-viewable notes about a page
- Organization Browser - Displays each person in the reporting chain in the interactive view optimized for browsing organization charts 
- Site Users
- User Tasks
Performance Point
- Performance Point Filter
- Performance Point Report
- Performance Point Scorecard
- Performance Point Stack Selector
Search
- Advanced Search Box
- Dual Chinese Search - Used to search Dual Chinese documentand items at the same time
- Federated Results
- People Refinement Panel - This web part helps the users to refine people search results
- People Search Box
- People Search Core Results
- Refinement Panel - used to refine results
- Related Queries
- Search Action Links
- Search Best Bets
- Search Box
- Search Core Results
- Search Paging
- Search Statistics
- Search Summary
- Search Visual Best Bet - displays visual best bets 
- Search Federated Results
Miscellaneous
- Chart Web Part - Helps you visualize yoru data on SharePoint Sites and portals

Display Javascript Popup with Server side code in sharepoint 2010

Simple add the below method in your code behind

public void Popup()
{
// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";

//String csname2 = "ButtonClickScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))
{

String cstext1 = "alert('Common are u still copying ...!');";

cs.RegisterStartupScript(cstype, csname1, cstext1, true);
}

}

Enable anonymous access on a Sharepoint site

To perform this procedure, an administrator must have enabled anonymous access for the Web application. If they haven’t done so, the Anonymous Access option does not appear.
Open the site on which you want to enable anonymous access.
On the Site Actions menu , click Site Settings.
Note: On a site for which the Site Actions menu is customized, point to Site Settings, and then click the settings that you want to view.
On the Site Settings page, in the Users and Permissions column, click Advanced permissions.
On the Permissions page, on the Settings menu, click Anonymous Access.
On the Change Anonymous Access Settings page, select the parts of your Web site that you want anonymous users to access.

Thursday, September 2, 2010

Get the URL of a List in Sharepoint

This is a seemingly simple task – given a List or Library in SharePoint, how do I get it’s URL? The difficulty here is that a List has multiple URLs – one for each View on the list. We can get those URLs, but sometimes you really just want the URL to the list, without the /forms/something.aspx bit too.
For example, you might want http://server/siteCollection/site/lists/somelist . If you entered this URL, you’d be taken to the default View for the list, so you don’t really need the extra /forms/… bit to identify the list – that’s all about identifying the view.
Sadly, though, there is no SPList.Url property or equivalent on the SPList object. So, how can I get a list’s URL? Well, all Lists have a RootFolder. This folder has a URL, relative to the SPWeb it’s in.
 So, we can do something like this:
string url = web.Url + "/" + list.RootFolder.Url
Well, that’s great – but the result has the full path, including the server name. This can differ in SharePoint with alternate access mappings, so it can be useful to get the server relative url instead. This can be slightly more complicated:
string url = "http://server/subsite/Documents/";
using (SPSite site = new SPSite(url))
{
    using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.GetList(url);
        string listurl = web.ServerRelativeUrl;
        if(listurl == "/") listurl = string.Empty;
        listurl = listurl + "/" + list.RootFolder.Url;
        Console.WriteLine(listurl);
    }
}
This should give use the server relative URL for the list. Note also the bit where we clear our variable if we are in the root site of the root site collection of a web application (e.g. http://server/ ) as this returns an SPWeb.ServerRelativeUrl of “/”

The Top Three hottest new majors for a career in technology.

The following is my list of the Top Three hottest academic areas for a future career in tech:
Data Mining/Machine Learning/AI/Natural Language Processing
All of these fields help us sift through and organize huge amounts of information or data. When you apply your knowledge in these areas to a challenging problem in the online space, you know that you are working at a scale that is just immense.  It’s much easier said than done.  If you have a passion for this area and have a technical background there are a multitude of open positions that might hold a long-term career for you.  With the move to the cloud and the sheer amount of information on the web, this area of expertise will continue to be in great demand. Microsoft has a great need for both people interested in the research space and the applied space which is very refreshing.
Business Intelligence/Competitive Intelligence
The ability to see trends, make sense of data to a business audience and help to understand your customers requires a special person. Someone with a mix of engineering, BI/CI experience and a business mindset can take this field to the next level. You will help increase any employer’s bottom line and be able to provide organized data that is extremely valuable to any business. You can help drive business decisions and help your internal audience understand what the data is telling or showing you.
Analytics/Statistics – specifically Web Analytics, A/B Testing and statistical analysis
All of these subjects are offshoots of traditional degrees in CS and mathematics. They all apply to the online world we live in and will also be in great demand as we continue to monetize the web. Retailers, web services, and advertisers will need people in these fields as they try to get the most for their advertising money. As we continue to see the dollar amounts spent for online advertising worldwide, these fields will be hot and we will see online advertising change over time as a result of these positions.
If these fields interest you and you want to find out what some of these jobs really entail, visit our website and search on the terms above to get a more detailed look at the positions. These fields are very HOT and looking long term, the demand will be just that much greater in these areas.

Wednesday, September 1, 2010

C# 3D Array

C# makes the distinction between jagged and multi-dimensional arrays. Elements of a multi-dimensional array are stored in a contiguous block in memory while elements of a jagged array are not. Java arrays are actually jagged arrays, while C# supports both and allows you to choose which one you want based on the syntax of your code. Note that multi-dimensional arrays are better (in most cases) than jagged arrays.
Using jagged arrays in C# is not as simple as in Java. It’s almost like the way we would implement it in C++. 
int[][] jaggedArray = new int[2][];
jaggedArray[0] = new int[4];
jaggedArray[1] = new int[3]; 
However, multi-dimensional arrays in C# are very simply to use. You can create a 3 dimensional array as follows:
int[,,] array3D = new int[x, y, z]; 
then access its elements at array3D[i][j][k].
Sample Code: 
static void Main(string[] args)
{
    //  Array 3 Dimensions    int x = 4, y = 5, z = 6;

    //  Array Iterators    int i, j, k;

    //  Allocate 3D Array    int[,,] array3D = new int[x, y, z];

    //  Access array elements    for (i = 0; i < x; i++)
    {
        Console.WriteLine(i);

        for (j = 0; j < y; j++)
        {
            Console.WriteLine();

            for (k = 0; k < z; k++)
            {
                array3D[i, j, k] = (i * y * z) + (j * z) + k;
                Console.Write("\t{0}", array3D[i, j, k]);
            }
        }

        Console.WriteLine('\n');
    }
}