Showing posts with label SharePoint Coding. Show all posts
Showing posts with label SharePoint Coding. Show all posts

Monday, July 15, 2013

Difference between SharePoint Application Pages and Site Pages

SharePoint Application Pages Vs Site Pages


Application Pages: 
  • Application pages are stored in the server's file system.
  • SharePoint Designer tool cannot be used with application pages.
  • Application pages cannot be used within Sandboxed solutions.
  • An Application page cannot be customized and modified by end user, instead a developer is required.
  • These are the normal .aspx pages deployed within SharePoint. Most common of them are the admin pages found in _layouts folder.
  • These are deployed either at the farm level or at application level. If they are deployed within _layouts folder or global SharePoint Virtual Directory, then they can be used by any SharePoint application (available at farm level), otherwise they can be deployed at application level only by creating a virtual directory.
  • These are typical ASP.Net aspx pages and can utilize all of the functionalities available within ASP.Net including code-behind, code-beside, inline coding etc.
  • These are compiled by .Net runtime like normal pages.
  • Since application pages are compiled once, they are much faster.
  • If you deploy your custom ASPX pages within _layouts folder or within SharePoint application using a virtual directory, you will not be able to use SharePoint master pages and have to deploy your master page within the virtual directory or _layouts folder.
  • Application Pages cannot use contents as this concept is associated with SharePoint Page Layouts not with ASP.Net.
  • Normally application pages are not web part pages, hence can only contain server controls or user controls and cannot be customized by the end users.
  • Easiest way to deploy your existing ASP.Net web site within SharePoint is to deploy its pages as Application Pages within SharePoint. In this way you can convert any ASP.Net web solution as SharePoint application with minimal efforts.
  • SharePoint specific features like Information Management Policies, Workflows, auditing, security roles can only be defined against site pages not against application pages.
Site Pages:
  • Site Pages is a concept where complete or partial page is stored within content database and then actual page is parsed i.e. it takes content from content database and layout from the file system folder at runtime and delivered to end-users.
  • Site pages can be edited by using SharePoint Designer tool.
  • Site pages are used within Sandboxed solutions
  • A site page can be customized and modified by end user
  • They are slower as compared to Application pages as they are parsed every time they are accessed.
  • Pages stored in Pages libraries or document libraries or at root level within SharePoint (Wiki pages) are Site Pages.
  • Another advantage is they are at user-level not at web-application or farm level and can be customized per site level.
  • In Site Pages, users cannot add the code. However Best way of adding any inline code to these pages is through web-parts, server controls in master pages, user controls stored in "Control Templates" folder or through smart parts. 
  • If you want to add any inline code to master page, first you need to add following configuration within web.config:
<PageParserPaths> <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>

Tuesday, May 7, 2013

Sharepoint Products Configuration Wizard- Could not load file or assembly ‘Microsoft.IdentityModel’


Could not load file or assembly ‘Microsoft.IdentityModel Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot fine the find specified.
Current "Assembly": 1.0.0.0



The reason for receiving this error is because I don’t have the Windows Identify Foundation Pack installed on my Windows 7 machine.  To resolve this problem, I downloaded and installed the Windows Identity Foundation Pack.

This error is occured as we don't have the assembly 3.5.0.0 version in Windows Identity Foundation.
Latest Assembly is 3.5.0.0


Download: Windows6.1-KB974405-x86.msu



Wednesday, January 2, 2013

Using the Dialog framework in SharePoint 2010


Dialog framework

Another addition in SharePoint 2010 is the Dialog framework. For the most part, this is encapsulated in the functionality exposed by the SP.UI.Dialog and SP.UI.ModalDialog classes. Although the notifications and status bar functionality is included in the SP.js file, the dialog framework code is included in the SP.UI.Dialog.js file. To get IntelliSense support in Visual Studio when writing JavaScript that targets the dialog framework, add the following reference element to the JavaScript file:
1/// <reference path="C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTSSP.UI.Dialog.debug.js" />
Showing a modal dialog is a relatively straightforward affair. First, we create a DialogOptions object, and then we call the showModalDialog method of the SP.UI.ModalDialog object, as this sample shows:
1function ShowDialog_Click() {
2var options = { url: 'http://www.chaholl.com',
3title: 'My Dialog',
4allowMaximize: false,
5showClose: true,
6width: 150,
7height: 150,
8dialogReturnValueCallback: SendNotification_Click    };
9var did = SP.UI.ModalDialog.showModalDialog(options); }
In this sample, we’re redirecting to an Internet page for the sake of simplicity. In a real-world application, we’d create a custom page that implemented the required functionality. In Chapter 9, you’ll see examples of custom dialogs when we build settings pages for service applications.
The important thing to note about the DialogOptions object is the dialogReturnValueCallback property. This contains details of a callback method that will be called when the dialog is closed. In this callback, we can write code to pick up the dialog result and perform any necessary actions. In this simple example, we’ve generated a notification using our notification sample code.

Creating a new dialog page

One of the first things we want to do when using the dialog framework is to create a new page that will form our dialog. As the short sample above shows, a dialog can be any web page. However, for the sake of consistency, we’ll create a dialog that uses the look and feel of other SharePoint 2010 dialogs.
Using Visual Studio 2010, create a new Empty SharePoint Project as shown.
image
Set the local site to whatever the url is for your SharePoint 2010 dev server and choose the Deploy as farmsolution option.
Currently there is no SPI for creating dialog pages in Visual Studio. I intend to submit one to the CKSDev project in the near future so hopefully this will be resolved soon. In the meantime we can manually configure a dialog page using the Application Page SPI as shown. Add a new application page named MyTestDialog.aspx.
image
Visual Studio will automatically add a mapped folder for the %SPROOT%/Template/Layouts folder and will add our new application page in a folder named after our project. So far, so good!
In SharePoint 2010, all system generated dialogs are based on the dialog.master master page that can be found at %SPROOT%/Template/Layouts/Dialog.master. To ensure consistency with other dialogs we’ll use this master page as the basis for our test dialog.
In the MyTestDialog.aspx page, amend the Page tag as follows:
1<%@ Page Language="C#"
2    AutoEventWireup="true"
3    CodeBehind="MyTestDialog.aspx.cs"
4    Inherits="ModalDialogSample.Layouts.ModalDialogSample.MyTestDialog"
5    MasterPageFile="~/_layouts/dialog.master" %>

What’s the difference between MasterPageFile and DynamicMasterPageFile?

Notice the use of the MasterPageFile attribute as opposed to the DynamicMasterPageFile attribute that was inserted by default as part of the application page template. The DynamicMasterPageFile attribute can only reference ~masterurl/default.master or ~masterurl/custom.master and provides a mechanism for SharePoint to dynamically alter the master pages that are applied to a page. Since we’re not using this functionality we must use the standard MasterPageFile attribute and a relative path to our dialog.master file.
Since we’ve changed the master page, the content tags present in the application page template will no longer tie up correctly to Placeholder tags in our dialog.master. Delete the default content tags and replace with the following markup:
01<asp:Content ID="Content1"
02ContentPlaceHolderID="PlaceHolderDialogHeaderPageTitle"
03runat="server"> My Test Dialog Title </asp:Content>
04<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
05  <SharePoint:CssRegistration ID="CssRegistration1" runat="server" Name="ows.css" />
06  <SharePoint:ScriptLink ID="ScriptLink1" Language="javascript" Name="core.js" runat="server" />
07  <SharePoint:FormDigest ID="FormDigest1" runat="server" />
08</asp:Content>
09<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderDialogImage" runat="server">
10  <img src="/_layouts/images/allcontent32.png" alt="" />
11</asp:Content>
12<asp:Content ID="Content5" ContentPlaceHolderID="PlaceHolderDialogBodyHeaderSection"runat="server">
13</asp:Content>
14<asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderDialogDescription" runat="server">
15  <div id="selectTermDescription" class="none-wordbreak">
16    <table class="ms-dialogHeaderDescription">
17      <tbody>
18        <tr>
19          <td>This is description text for a custom dialog</td>
20        </tr>
21      </tbody>
22    </table>
23  </div>
24</asp:Content>
25<asp:Content ID="Content8" ContentPlaceHolderID="PlaceHolderHelpLink" runat="server">
26  <!-- Remove the default help link -->
27</asp:Content>
28<asp:Content ID="Content6" ContentPlaceHolderID="PlaceHolderDialogBodyMainSection"    runat="server">
29  This is the body section of our test dialog
30</asp:Content>