1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Exploring SharePoint 2013 Development Options

Discussion in 'ASP.NET' started by MinalS, Apr 26, 2015.

  1. MinalS

    MinalS New Member

    Jul 8, 2014
    Likes Received:
    Trophy Points:
    Application and Solution Types
    1. Sandboxed solutions: It is a light weighted solution that is deployed to the sandbox environment and it is deployed to Office 365 or on SharePoint installations.
    2. Farm level solution: It is connected with either SharePoint server or foundation. The solution is installable and accessed by any site collection within the SharePoint farm.
    3. SharePoint hosted apps: It is a light weighted app deployed to SharePoint but has client side code as HTML, JavaScript, and CSS.
    4. Cloud hosted apps: The apps that are hosted in the cloud and can be deployed on SharePoint or Office 365. They are provider hosted or auto hosted.
    Farm level solutions

    The farm level solutions are used for applications which are deployed to SharePoint server or foundation. They can be used for enterprise grade solutions. The application scope is only for farm level or site collection. It is based on the Site architecture. It provides with the server code and does not have any limitations.

    Sandboxed solutions

    The sandboxed solutions provide strategic direction to the cloud hosted model. The app scope is for sandboxed solutions only. They are based on Site architecture. The .NET developers can build the applications. They are limited OM, and extensibility.

    SharePoint hosted

    It is useful when small, light weighted apps which are specific to a site collection or SharePoint page is useful. When there are server side requirements it is not useful.
    It provides HTML and JavaScript development skills.

    Cloud hosted apps

    They are used when the user does not want any running code on the server. The Autohosted is used for small scale apps and the provider hosted is used for enterprise grade cloud apps. The REST APIs or client side object model is useful for substituting the server side object model functionality.

    Developer Tasks

    User can build different apps types using SharePoint 2013. There are some common tasks that user can perform often. Some of the common tasks are as mentioned below:
    1. Creating web parts
    2. Creating SharePoint hosted apps
    3. Working with SharePoint data
    4. Creating ASPX pages
    5. Creating Master Pages

    1. Creating web parts

    The most common task is the creation and deployment of the web part. In SharePoint 2013, there are three different web parts as standard, visual and Silverlight. The ASP.NET objects, containers or the IFRAME provide dynamic client side code. The Visual and Silverlight web parts are more used because of the rich designer capabilities.

    Standard web parts

    The standard web part provides creation of web parts and deploys them at SharePoint. When user creates a standard web part, the objects are created from the base and assemble the web part.

    The following code snippet demonstrates the standard web part creation.

    namespace WebPart1
        [ToolBoxItemAttribute(false) ]
        public class WebPart1 : WebPart
            Label label1 = new Label();
            TextBox txt1 = new TextBox();
            Label label2 = new Label();
            Button button1 = new Button();
            protected override void CreateChildControls()
                label1.Text="Enter the value";
                label2.Text=" “;
                txt1.Text=" “;
                this.Controls.Add(new LiteralControl(“<br/>"));
                this.Controls.Add(new LiteralControl(“<br/>"));
                button1.Click+=new EventHandler(button1_Click);
            void button1_Click( object sender, EventArgs e)
                string username = txt1.Text;
    In the above code, the textbox, label and button control is instantiated, properties are set. The Click event corresponding to the button control is added. The four controls are created at the class level. The CreateChildControls method is used to add the properties to the objects. The Add method is used to add the controls to the collection. The click event is used to add the user entry to the labels.

    Visual web parts

    The Visual web part is different in designing for creating the User Interface for the web part. User can easily add the controls and the code behind for the web part type. The ASP.NET constructs can be used for the creation of the visual web part.

    User can drag and drop the controls in the web part UI. A wide library controls can be added from the toolbox to the designer window. User can double click the control in the designer view and add the code in the code behind file.

    The following code snippet shows the visual web part creation.

     <asp:Label ID="label1" runat="server" Text="Enter name"></asp:Label>
    <asp:TextBox ID="txt1" runat="server"></asp:TextBox>
        <asp:Label ID="label2" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="btn1" runat="server" onclick="btn1_Click" Text="Click" />
    The code behind file for the ASCX control is as shown below:

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebContorls.WebParts;
    namespace WebPart2
        public partial class WebPart2UserControl: UserControl
            protected void btn1_Click(object sender, EventArgs e)
                string response = txt1.Text;
    The control declarations are not present in the ASCX code behind file. The core web part class contains the reference. The following code shows the reference inside the core web part class.

    public class WebPart2 : WebPart
        private const string _ascxpath = @"~/_CONTROLTEMPLATES/WebPart2UserControl/WebPart2/WebPart2UserControl.ascx";
        protected override void CreateChildControls()
            Control control = Page.LoadControl(_ascxpath);
    Silverlight web part

    The Silverlight web part provides user a way to deploy rich media applications to SharePoint. It combines a web part and silverlight application into a single project. The Web Part contains a container that points to the application and deploys to SharePoint.

    The rich media applications, data bound applications, and applications that user can use across all the versions of SharePoint.

    2. Creating SharePoint hosted apps

    SharePoint hosted apps are included the SharePoint 2013 version. The applications are light weighted, client side code, no heavy back end process elements.

    User can create common SharePoint artifacts that can be used commonly by the user. They are lists, content types, and site columns. They are deployed on cloud hosted, or on premises instance.

    The list type are the core part of the SharePoint development. It consists of object model that can be used for coding. The content types are also reusable object that user can repurpose across the site. Content types are available in various shapes and sizes. The content type can be bind to the list definitions.

    3. Working with SharePoint data

    There are data sources like list or document libraries with which user needs to work. There are various options with which user can interact with the data. The Server Object Model, Client side object model, REST services, SharePoint services are used for communication.

    User needs to create a connection with the SharePoint site. Add the reference of the Microsoft.SharePoint.dll or Microsoft.SharePoint.Client.dll to the project. User can now add the code and the context to the application. The using statement is used wrap the code. The site collection can be set to either OpenWeb method on the site or RootWeb property.

    using ( SPSite sitecollection = new SPSite ( mysiteUrl) )
        using ( SPWeb SPSite1 = sitecollection.RootWeb )
            //Add the code here
    The SharePoint client side object model is used to read and write the data from the SharePoint lists. The references Microsoft.SharePoint.Client.Runtime.dll and Microsoft.SharePoint.Client.dll references are added. The ExecuteQuery is used to process the code. The Close statement is used to dispose the context.

    String mySiteUrl = “http://newteam/ireland";
    ClientContext  mySiteContext = new ClientContext ( mySiteUrl);
    // Add the code here

    4. Creating ASPX pages

    The SharePoint is built on the ASP.NET, the pages in the SharePoint are of the specific type. The SharePoint ASPX pages are different from the ASP.NET sites as they contain native capabilities that are built in ASPX page.

    When a new ASPX page is created, it derives the parent features and loads and registers dependent assemblies needed to render the page and controls.

    User can create simple ASPX page from SharePoint without any obstructions that the Web Parts page delivers. The following code shows the ASPX page but it does not contain any SharePoint controls.

    <!DOCTYPE html PUBLIC “~//W3C/DTD XHTML 1.0 Strict //EN" 
    <%@ Page Language="C#" %>
    <html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <meta name="WebPartPageExtension" content="full" />
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Untitled 1</title>
    <body><form id="form1" runat="server">
    The HTML markup for the ContentPlaceHolder controls and ASP.NET controls are interlaced. The ContentPlaceHolder control is used to render the functional controls or application on ASP pages.

    The following code snippet shows the ContentPlaceHolder controls.

    <asp:contentPlaceHolderId="PlaceHolder1" runat="server">
        <SharePoint:DelegateControl runat="server" ControlId="InputValue" />

    5. Creating Master Pages

    Master pages are an ASP.NET creation which SharePoint inherits from it. It used master pages to provide consistent structure and layout for every page in the site. A single master page can provide multiple sites a look and feel for all the pages.

    When user installs a SharePoint, it has a single master page to the site as default. The copy of default.master master page is created and user can customize it. The designer provides user with capabilities to manage, create and edit the master pages.

    It produces a combined layout containing the master and content pages from the site page. The following code shows the reference to the master page.

    <%@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint.Version=, Culture=nuetral" 
    meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
    The master page has the .master file extension. It contains an array of objects. The master page contains the breadcrumbs and default menu and navigation options specific to SharePoint.

    The ContentPlaceHolder objects contain regions where the controls appear. The controls need to be placed when the master pages are customized. More content place holders can be added to the page.

    The following code snippet shows the different types of text and controls that are present in the SharePoint site.

    <title id="Title1"><asp:ContentPlaceHolder id="PlaceHolderTitle" runat="server" />
    <SharePoint: CssLink runat="server" Alternate="true" />
    <SharePoint: Theme runat="server" />
    <SharePoint: CssRegistration Name="min1.css" runat="server" />
    <SharePoint: CssRegistration Name="layout.css" runat="server" />
    <span class="s2">
        <a href="javascript:;" onclick="jaavscript:this.href="#maincontent’;"
        class="ms-SkipToContent" accesskey="<%$Resources:wss,maincontent-accesskey%>" runat="server" >
        <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss, mainContentLink%>" EncodeMethod="HtmlEncode" />
    <asp:ContentPlaceHolder id="PlaceHolderMenu" runat="server">
    <div class="lb ms-mini-trcMenu">
        <wssuc: Welcome id="Wel1" runat="server" EnableViewState="false">
    <asp:ContentPlaceHolder id="PlaceHolder2" runat="server">
    <div id="Dashboard1" class="ms-dashboard1">
    <SharePoint : Dashboard1 runat="server" />

Share This Page