Showing posts with label Sharepoint 2010. Show all posts
Showing posts with label Sharepoint 2010. Show all posts

Sunday, December 11, 2011

ADO.NET Data Services and REST

ADO.NET Data Services is yet another way for you to access your SharePoint data at client side. Under
this technology you would use patterns and libraries that make data accessible over simple HTTP-based
technologies. This means that you can access the data over simple HTTP-based URIs and use of
standard HTTP verbs such as GET, PUT, POST, and DELETE. Data is fetched in JSON or ATOM formats,  so it is portable across all platforms.

Tuesday, December 6, 2011

Adding a Custom Action to a SharePoint 2010 Display Form


It is common when customizing SharePoint 2010 to want to extend the user interface. Fortunately, this is easy to do by using the ribbon menu. You can add new functionality to the SharePoint 2010 ribbon as custom actions. Custom actions enable you to expand or extend the standard behavior of SharePoint 2010 core components such as using a custom action to email the details of a list item.
This topic describes two approaches for adding a custom action to a display form of SharePoint 2010 list items. The custom action is added to the ribbon as a button.
You have two options to add custom actions to a display form:
  • Adding a custom action through SharePoint 2010 features. SharePoint features enable you to easily deploy customizations. This is the preferred method when you need to package the customizations and deploy them to different servers.
  • Adding a custom action by using Microsoft SharePoint Designer 2010. SharePoint Designer helps create rapid, no-code customizations on the local server.

Custom Action Elements

 

Creating a Custom Web Part Editor in SharePoint 2010


The Microsoft SharePoint 2010 Web Part framework enables users to configure a Web Part through Web Part properties. A default user interface (UI) is given for each Web Part property that is exposed to the user in the Edit Tool pane of the Web Part. For example, a property of type String is rendered as a text box, and an Enum is rendered as a drop-down list box.
This default rendering by the framework does not allow for much customization because the user cannot get a handle to the controls that are rendered. For example, it has the following limitations:
  • Control over UI: Numeric and string types are rendered as text boxes, enumeration types are rendered as a drop-down list box, and Boolean types are rendered as check boxes. So, you cannot show an enumeration type as radio buttons instead of a drop-down list box.
  • Events: Events that are raised by the controls cannot be handled; for example, you cannot enable or disable a drop-down list based on selecting a check box.
  • Validation: If user input has to be validated, the framework does not provide a way to easily attach a Microsoft ASP.NET validation control to the input control that is generated. For example, you cannot validate a string input for a valid email address through an ASP.NET RegEx validation control.
You can overcome these limitations by using custom editor parts. With custom editor parts, you can offer users functionality that can be achieved through ASP.NET user controls. A Web Part can implement custom editor parts that can be loaded when the Web Part is in edit mode, expose a custom UI, handle events, and validate inputs. A Web Part can have more than one custom editor part associated with it.
This article describes the SharePoint 2010 Web Part framework in detail and provides a code sample to show how to create a custom Web Part editor in SharePoint 2010. First, we examine the framework that enables custom editor parts.

Monday, November 21, 2011

Embedding YouTube Videos in SharePoint Wiki Page

In SharePoint Wiki Pages we can directly put the formatted text or HTML content. I faced an issue when I tried to embed a youtube video in a new wiki page by editing the HTML & adding the <object> embed code. When I saved the page, the <object> code was stripped out.

Then I tried another option. I inserted out-of-the-box Media Web Part, opened it in the Edit mode, and change media address to the youtube video address. It seems logical and it should work, but it didn't work and it shown an error message “Media failed to load.”

Then I looked around other possible options and found that there are following two approaches to achieve this:

product fixes included in the SharePoint 2010 Service Pack 1 (SP1):


Microsoft has released SharePoint 2010 Service Pack 1 (SP1) in the last week of June, 2011. This service pack includes all the public updates that were released through June 2011, and all the cumulative updates that were released through April 2011. It also consists of previously unreleased fixes that were made specifically for this service pack. In addition to general product fixes, this Service Pack also include enhancements and couple of new features.
Following are the various product fixes included in the SharePoint 2010 Service Pack 1 (SP1):



Friday, November 18, 2011

Creating, Deploying, and Debugging Custom Timer Jobs in Windows SharePoint

Windows SharePoint Services 3.0 lets you create custom jobs that are executed at set intervals. These jobs, known as timer jobs, are similar to those tasks that you can create in any version of Windows by using the Task Scheduler application. This capability is useful for scheduled process jobs because you keep everything in Windows SharePoint Services rather than create a console .exe file that is configured to run at set intervals by using the Windows Task Scheduler. The major benefits to using the Windows SharePoint Services timer service compared to using Windows Task Scheduler is that the timer service knows the topology of the Office SharePoint Server farm, and that you can load balance the jobs across all the servers in the farm or tie them to specific servers that are running particular services. This Microsoft Office Visual How To demonstrates how to create a job that requests the home page of each site collection in a Web application to force just-in-time (JIT) compilation and to speed up the first request.

public SharePointWarmupJob (SPWebApplication webApp)
  : base(JOB_NAME, webApp, null, SPJobLockType.ContentDatabase) {
    this.Title = JOB_NAME;
}
public override void Execute (Guid targetInstanceId) {
  if (this.WebApplication.Sites.Count > 0)
    WarmUpSiteCollection(this.WebApplication.Sites[0]);
}
private void WarmUpSiteCollection (SPSite siteCollecion) {
  WebRequest request = WebRequest.Create(siteCollecion.Url);
  request.Credentials = CredentialCache.DefaultCredentials;
  request.Method = "GET";
  WebResponse response = request.GetResponse();
  response.Close();
}

Creating a Solution Package in Windows SharePoint

Microsoft Windows SharePoint Services 3.0 introduces a deployment mechanism named "solution packages." A solution package is a CAB file with a .wsp file-name extension that contains all the files that must be deployed on the front-end Web server and a set of XML-based installation instructions. Windows SharePoint Services provides a rich infrastructure that simplifies deployment of solution packages in a Web farm environment.

<Solution SolutionId="44BE5F4A-D561-4981-A318-95ABC706364A" 
          xmlns="http://schemas.microsoft.com/sharepoint/">
  <FeatureManifests>
    <FeatureManifest Location="ItemAuditing\feature.xml" />
  </FeatureManifests>
  <TemplateFiles>
    <TemplateFile Location="LAYOUTS\AuditLogViewer.aspx"/>
    <TemplateFile Location="LAYOUTS\ItemAudit.aspx"/>
    <TemplateFile Location="LAYOUTS\AuditLogWorkbook.ashx"/>
  </TemplateFiles>
  <Assemblies>
    <Assembly DeploymentTarget="GlobalAssemblyCache" 
              Location="ItemAuditing.dll" />
  </Assemblies>
</Solution>

Creating a Custom HttpHandler in Windows SharePoint

ASP.NET programming supports the creation of custom HttpHandler components, which provide a flexible and efficient way to process requests that don't return standard HTML-based pages. For example, HttpHandler components are great for situations in which you want to return simple text, XML, or binary data to the user.
 
<%@ Assembly Name="Microsoft.SharePoint, [full assembly name]" %> 
<%@ WebHandler Language="C#" Class="HelloHttpHandler" %>
using System;
using System.Web;
using Microsoft.SharePoint;

Creating an Application Page in Windows SharePoint

You can create custom application pages to add user interface components to a custom solution based on Microsoft Windows SharePoint Services 3.0. Unlike site pages (for example, default.aspx), a custom application page is deployed once per Web server and cannot be customized on a site-by-site basis. Application pages are based in the virtual _layouts directory. In addition, they are compiled into a single assembly DLL. They are also used across all sites within a server farm. For these reasons, they perform better than site pages. With application pages, you can also add inline code. With site pages, you cannot add inline code

<%@ Assembly Name="Microsoft.SharePoint, [full 4-part assembly name]"%> 
<%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" 
         Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %>

<%@ Import Namespace="Microsoft.SharePoint" %>

Building Master Pages for Windows SharePoint

The Visual Studio 2005 extensions for Windows SharePoint Services 3.0 provide new support for creating SharePoint applications. The tools significantly simplify the process of creating SharePoint site definitions, with Microsoft Visual Studio 2005 automating the creation of the necessary content, configuration, and deployment files. This Office Visual How To illustrates how to build a Windows SharePoint Services 3.0 site definition and add a custom master page to the definition by using Visual Studio 2005 and Visual Studio 2005 extensions for Windows SharePoint Services 3.0.

Writing a Filter Provider Web Part for Windows SharePoint

This section walks through the five major steps to create the Geographic Region filter provider Web Part:
  1. Create a Web Control Library project in Microsoft Visual Studio 2005.

  2. Add a reference to the Windows SharePoint Services assembly.

  3. Set the Web Part assembly version number.

  4. Sign the Web Part assembly with a strong name.

  5. Add the code that implements the functionality of the Geographic Region filter provider Web Part.


Activating Auditing Programmatically for a Site Collection in Windows SharePoint

Overview
Microsoft Windows SharePoint Services 3.0 includes a powerful new infrastructure for auditing user access to list items, and documents and pages. In Windows SharePoint Services, auditing is configured on a site collection-by-site collection basis. It just takes a few lines of code to fully enable the auditing for an entire site collection. When you do this, Windows SharePoint Services writes an audit entry to its audit log each time a user views or modifies a list item, document, or site page.


Thursday, November 17, 2011

Sharepoint lookup field in list

A lookup field takes its value from a field in another list. The list that provides data for the lookup field is called the lookup list. To get a reference to the lookup list, access the SPFieldLookup object's LookupList property. To determine which field in the lookup list is providing information, access the LookupField property.

Although the SPFieldLookup class does have a constructor, it is often more convenient to call the AddLookup method of the SPFieldCollection class. The AddLookup method has an overload that you can use to create a lookup to a list in a different Web site from the one where you are creating the SPFieldLookup object.

Microsoft SharePoint Foundation supports multiple-column lookups. In this case, a primary column establishes the relationship with the lookup list by pointing to a field in the target list, and one or more secondary columns point to other fields in the target list. You can create the lookup field for a secondary column by calling the AddDependentLookup method of the SPFieldCollection class. For a secondary column, the IsDependentLookup property returns true. For a primary column, IsDependentLookup returns false and the IsRelationship property returns true.

SharePoint Foundation supports referential integrity for list items by making it possible for lookup fields to set deletion constraints on the lookup list. You do this through the RelationshipDeleteBehavior property, which takes one of the following SPRelationshipDeleteBehavior enumeration values:

Cascade . Deleting an item from the lookup list causes all related items to be deleted from the list that contains the lookup field.

Restrict . Prevents an item on the lookup list from being deleted if related items exist on the list that contains the lookup field.

None . No constraint (the default).

In order to specify either Cascade or Restrict, the user must have SPBasePermissions.ManageLists permission on the lookup list. In addition, both Cascade and Restrict require that the lookup field be indexed. Before setting the RelationshipDeleteBehavior property to either of these values, first set the Indexed property to true.


using System;

Sunday, November 13, 2011

Upload a File to a SharePoint Site from a Local Folder


Aspx Page

<form id="Form1" method="post" runat="server">
   <SharePoint:FormDigest runat="server" />
   <input id="File1" type="file" runat="server" title="upldFileBox">
   <asp:Button id="Button1" runat="server" 
      Text="Upload File"></asp:Button>
   <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</form>

Code Behind

Automatic Password Change and Managed Accounts


Automatic Password Change

The new automatic password change feature in Microsoft SharePoint Foundation enables you to update and deploy passwords without having to perform manual password update tasks across multiple accounts, services, and Web applications. This makes managing password in SharePoint Foundation simpler. You can use the automatic password change feature to determine whether a password is about to expire and to reset the password by using a long, cryptographically strong random string.

Managed Account

Elevation of Privilege


Elevation of privilege, a feature that was added in Windows SharePoint Services 3.0, enables you to programmatically perform actions in code by using an increased level of privilege. The SPSecurity.RunWithElevatedPrivileges method enables you to supply a delegate that runs a subset of code in the context of an account with higher privileges than the current user.
A standard use of RunWithElevatedPrivileges is:

A standard use of RunWithElevatedPrivileges is:

Set the Culture and Language


If your code runs outside the context of Microsoft SharePoint Foundation and calls into the SharePoint Foundation object model, when the code executes, the culture of the current thread is set according to the operating system settings of the computer on which the code is run. To interact with SharePoint Foundation, the current culture's user interface and formatting must be set to the values that are contained, respectively, in the Language and Locale properties of the SPWeb class. 

Working with List Objects and Collections

To perform actions on list data in a SharePoint Web site, you must first obtain an SPWeb object to serve as an entry point to the object model, allowing you to access lists, items, documents, users, alerts, and so on. For information about how to return SharePoint Web sites, see Getting References to Sites, Web Applications, and Other Key Objects.

Most classes in the Microsoft.SharePoint and Microsoft.SharePoint.Administration namespaces start with SP. Generally, classes in the Microsoft.SharePoint assembly that do not start with this prefix represent Web form controls.
SharePoint Foundation typically does not save modifications of object properties to the database until you call the Update method on the specified object. The following example shows how to change the title and description for the Tasks list.


SPList oList = oWebsite.Lists["Tasks"];
oList.Title="New_Title";
oList.Description="List_Description";
oList.Update();

Server Architecture

Server architecture and Administration namespace

Relationship Between Original and Converted Documents in SharePoint Server 2010


Microsoft SharePoint Server 2010 uses document library metadata to track which documents are actually converted copies of other documents. For each converted copy in a document library, SharePoint Server 2010 stores additional information in the following two fields:
  • ParentID   A string that represents the name of the original file on which the converted copy is based.
  • ParentVersionID   An integer that represents the version number of the original file on which the converted copy is based.
The original file is not altered in any way, and includes no references to any converted copies generated from it.
These two columns enable SharePoint Server 2010 to determine which documents in a library are actually converted copies, and determine the original from which a specific converted copy was generated. For example, SharePoint Server 2010 uses this information to list the converted copies available for an original file on that document's settings page in the user interface.
Users can use this information also; for example, to create views that filter out the converted copies included in a document library.
The ParentID and ParentVersionID fields are columns that are actually included on each
document library in SharePoint Server 2010. However,
the columns are hidden for document libraries in Web applications that do not have
document converters enabled.
The relationship between the original file and any converted copies remains only as long as both the original file and the copy are located in the same document library. It is a one-way relationship; SharePoint Server 2010 stores information on the converted copy that references the original document, but includes no references from the original document to the copy.any converted copies.
Altering Files After Document Conversion

Featured Posts

Kali Linux Remote Desktop: Access GNOME from Windows Using Native RDP

  Kali Linux + GNOME 50 + GNOME Remote Desktop + Windows Remote Desktop (MSTSC) Getting a full GNOME desktop remotely on Kali Linux can be ...