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

Friday, November 23, 2012

Create a Visual Web Part Sandbox Solution



Create a Visual Web Part Sandbox Solution

In this task, you will create a sandboxed solution compatible Visual Web Part project.
Start Visual Studio 2010.
•Click File >> New >> Project.
•In the New Project dialog, under Installed Templates, select Visual C# >> SharePoint >> 2010 and select Empty SharePoint Project as the template.
•In the Name: textbox, enter SandboxSolu.
•In the Location: textbox, enter   a convenient location and click OK.
•In the SharePoint Customization Wizard, enter the URL of the on-premises site you created.
•Select Deploy as a sandboxed solution and click Finish.
•In the Solution Explorer, right-click the SandboxSolu project and select Add >> New Item.
•In the Add New Item – SandboxVWP dialog, select the Visual Web Part (Sandboxed) item and click Add.
In the Solution Explorer, double-click to open the VisualWebPart1 project item.Switch to Source view to edit the markup of the visual web part.
Add the following markup to the body of the page to add a label, drop down list, button, and a GridView control to the body of the visual web part. 
HTML

<p> Select List:
 <asp:DropDownList ID="ddlList" runat="server" /> </p>
 <asp:Button ID="ShowGrid" runat="server" OnClick="ShowGrid_Click" 
Text="Populate Grid!" /> <p> 
<asp:GridView ID="gridListItem" runat="server" /> </p> 


Click the Design button to toggle into design view. The visual web part should now look like:



Open the code behind of the visual web part by right-clicking anywhere on the design surface and selecting View Code. Add the following using directives to the top of the code behind file to reference the proper LINQ namespaces.
using System.Linq;

using System.Collections.Generic;
if (!Page.IsPostBack)
{
    SPWeb web = SPContext.Current.Web;
    var Names = from SPList list in web.Lists
                    where list.BaseTemplate != 
                        SPListTemplateType.DocumentLibrary
                    select list.Title;
    ddlList.DataSource = Names;
    ddlList.DataBind();
}

Switch back to the Design view of the visual web part.
•Double-click on the Populate Grid! button to create the event handler for the button’s click event.
•Locate the ShowGrid_Click event handler add the following code:

SPList SourceList = 
    SPContext.Current.Web.Lists.TryGetList(ddlLists.SelectedValue);
SPQuery qry = new SPQuery();
qry.ViewFieldsOnly = true;
qry.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='Author' />";
qry.RowLimit = 20;
gridListItem.DataSource = SourceList.GetItems(qry).GetDataTable();
gridListItem.EmptyDataText =
    string.Format(
        "The {0} list does not contain any items!",
        SourceList.Title);
gridListItem.DataBind();




Testing the Visual Web Part
Hit F5 to deploy the package to your local SharePoint 2010 instance and debug the project. Visual Studio 2010 will compile and deploy the project, activate the feature and open the specified SharePoint site in a browser window.
Click the Edit icon at the top of the page to put the page in Edit mode:
•Click the Web Part ribbon button to insert the web part.
•Under Categories select Custom, and under Web Parts select VisualWebPart1 Title. Click Add to add the web part to the page. The web part is now added to the page and is ready to test.

Click the Save button to save the changes you made to the page.

To test the web part, select a list in the drop down list and click the Populate Grid! button. The grid should show the items from the list or a message that the list does not contain any items.

Happy Programming..







Thursday, November 22, 2012

Sandbox Solutions in SharePoint 2010



  Sandbox Solutions in SharePoint 2010




Sandbox solution is a new feature introduced in SharePoint 2010. It’s a secured wrapper around webparts and other elements with limitations. There is no thumb rule that every webpart in SharePoint 2010 belongs to Sandbox Solution. But it’s recommended to develop webparts with Sandbox solution.
It allows administrators to monitor the solutions and control as required. SharePoint Site Collection administrators can view the resource utilization of each solution and can block if it consumes too much resources

 It allows administrators to monitor the solutions and control as required. SharePoint Site Collection administrators can view the resource utilization of each solution and can block if it consumes too much resources
 
SharePoint solutions run in seperate worker processes and not in w3wp.exe. So It doesn’t require IIS Reset or Application Pool Recycling. Without disturbing the SharePoint site, Sandbox solutions can be deployed. Only thing while deploying new version of Sandbox solution over existing solution, SharePoint will display No Solution found error in Sandbox Webparts on the page. However within seconds sandbox solutions getting deployed and it’ll start working

Sandbox Limitations
 Sandbox is a secured wrapper and it has restrictions on code to run in SharePoint environment. Few Key limitations which developers should know are listed below.
No Security Elevation - RunWithElevatedPrivileges which runs the specified block of code in application pool account(typically System Account) context is not allowed in Sandbox code. SPSecurity class also not allowed to use in Sandbox.
No Email Support - SPUtility.SendMail method has been blocked explicitly in Sandbox, However .Net mail classes can be used to send mails. Additionaly sandbox won’t allow to read Farm SMTP address. So developers has to specify the SMTP address in code itself.
No Support to WebPartPages Namespace - Sandbox won’t allow to use Microsoft.SharePoint.WebPartPages namespace.
No Support to external Webservice - Internet web service calls are not allowed to ensure security in Sandbox solutions.
No GAC Deployment - Sandbox solutions are not stored in File System(Physical path) and assemblies can’t be deployed to Global Assembly Cache(GAC).
No Visual Webparts - Visual Studio 2010 by default won’t allow to create Visual Webparts to deploy as sandbox solution. But with Visual Studio PowerTools extensions Visual Webparts can be developed and deployed as sandbox Solutions.

 

Thursday, November 1, 2012

Web Parts in SharePoint Foundation


Web Parts in SharePoint Foundation




Web Parts are server-side controls that run inside the context of site pages in Microsoft SharePoint Foundation. There are many Web Parts available by default, and you can also build your own custom Web Parts in SharePoint Foundation. They are editable and configurable by users. Web Parts let users add functionality to a site page by simply putting them on the page. SharePoint Foundation includes many default Web Parts. In addition, you can build your own Web Parts.
Types of Web Parts

There are two types of Web Parts in SharePoint Foundation. 
<!--[if !supportLists]-->·         <!--[endif]-->ASP.NET Web Parts — These Web Parts are built on top of the ASP.NET Web Part infrastructure.These Web Parts  makes them highly reusable.
<!--[if !supportLists]-->·         <!--[endif]-->SharePoint-based Web Parts —  These Web Parts can only be used in SharePoint websites.

Custom Web Parts
Custom Web Parts provide you with a method to create user interface elements that support both customization  and personalisation.
The term customization implies that changes are seen by all site members. Individual users can further personalize  Web Parts page by adding, reconfiguring, and removing Web Parts.  A site owner or a site member who has the appropriate permissions can customize Web Parts page by using a browser or by using Microsoft SharePoint Designer to add, reconfigure, or remove a Web Part.
.The following are some ways in which you can benefit from and use custom Web Parts:
<!--[if !supportLists]-->·         <!--[endif]-->Create custom properties that you can display and modify in the user interface.
<!--[if !supportLists]-->·         <!--[endif]-->Improve performance and scalability. A compiled custom Web Part runs faster than a script.
<!--[if !supportLists]-->·         <!--[endif]-->Implement proprietary code without disclosing the source code.
<!--[if !supportLists]-->·         <!--[endif]-->Secure and control access to content within the Web Part. Built-in Web Parts enable any users who have the appropriate permissions to change content and alter Web Part functionality. With a custom Web Part, you can determine the content or properties to display to users, regardless of their permissions.
<!--[if !supportLists]-->·         <!--[endif]-->Make your Web Part connectable, allowing Web Parts to provide or access data from other connectable Web Parts.
<!--[if !supportLists]-->·         <!--[endif]-->Interact with object models that are exposed in SharePoint Foundation. For example, you can create a custom Web Part to save documents to a SharePoint Foundation document library.
<!--[if !supportLists]-->·         <!--[endif]-->Control the Web Part cache by using built-in cache tools. For example, you can use these tools to specify when to read, write, or invalidate the Web Part cache.
<!--[if !supportLists]-->·         <!--[endif]-->Benefit from a rich development environment with debugging features that are provided by tools such as Microsoft Visual Studio 2010.
<!--[if !supportLists]-->·         <!--[endif]-->Create a base class for other Web Parts to extend. For example, to create a collection of Web Parts that have similar features and functionality, create a custom base class from which multiple Web Parts can inherit. This reduces the overall cost of developing and testing subsequent Web Parts.
<!--[if !supportLists]-->·         <!--[endif]-->Control Web Part implementation. For example, you can write a custom server-side Web Part that connects to a back-end database, or you can create a Web Part that is compatible with a broader range of Web browsers.

In SharePoint Foundation 2010, Web Parts are organized in the following categories:
<!--[if !supportLists]-->·               <!--[endif]-->Lists and Libraries
<!--[if !supportLists]-->·              <!--[endif]-->Content Rollup
<!--[if !supportLists]-->·              <!--[endif]-->Documents
<!--[if !supportLists]-->·              <!--[endif]-->Forms
<!--[if !supportLists]-->·              <!--[endif]-->Media and Content
<!--[if !supportLists]-->·              <!--[endif]-->People

  Certain Web Parts can only be used with particular types of lists, libraries, or content or pages. For example, the Task Details, Task Decision Makers can only be used in a Task list.






Tuesday, September 18, 2012

Introduction to SharePoint 2010


SharePoint 2010


Introduction 
Microsoft SharePoint is a software platform  developed by Microsoft for collaboration, file sharing and web publishing.

SharePoint mainly helps team members to connect and exchange information in a collaborative manner. It helps to centralize enterprise information for efficient functioning.
Microsoft SharePoint 2010 makes it easier for people to work together. Using SharePoint 2010, we can
  •  Set up Web sites
  •  Manage documents 
  •  Publish reports .

Benefits of SharePoint 2010:

1.      FOR IT PROFESSIONALS
·         SharePoint 2010 make a company more productive.
·          Flexible deployment options.
·         Centralized administration and management features, we can maintain control over a system that is ready to respond to any business need.

2.      FOR DEVELOPERS: 
·        SharePoint 2010, helps to  build custom applications and components that  responds rapidly  to business needs.
·         Ease of  creating  Web Parts, external content types, and workflow activities for use in SharePoint solutions.
·      SharePoint implementations can be customized  using a  full set of extensibility APIs.

3.      FOR END USERS: 
·         SharePoint 2010 makes a  better, faster, and smarter team.
·         Access the right people and information at the right time to make better decisions .
·         SharePoint 2010  provides familiar interface and direct connections to Microsoft Office.

Components of SharePoint:

1.       SITESSharePoint 2010 Sites provides a single infrastructure for all your business        Websites. Share documents with colleagues, manage projects with partners, and     publish information to customers. 

2.      COMMUNITIES: SharePoint 2010 Communities delivers great collaboration tools     and a single platform to manage them. Make it easy for people to share ideas and   work together the way they want.

3.      CONTENT: SharePoint 2010 Content makes content management easy. Set up      compliance measures ”behind the scenes”—with features like document types,     retention polices, and automatic content sorting—and then let people work     naturally in Microsoft Office.

4.      SEARCH: SharePoint 2010 Search cuts through the clutter. A unique combination of    relevance, refinement, and social cues helps people find the information and    contacts they need to get their jobs done.

5.      INSIGHTS: SharePoint 2010 Insights gives everyone access to the information in    databases, reports, and business applications. Help people locate the information    they need to make good decisions.

6.      COMPOSITES: SharePoint 2010 Composites offers tools and components for    creating do-it-yourself business solutions. Build no-code solutions to rapidly    respond to business needs.

Purpose of SharePoint:

 1)  Mainly used as  Portal Collaboration Software.   

2)    We can have  greater control over the storage, security, distribution, and management of their electronic content, with tools that are easy to use in everyday applications.

3)    Organizations can accelerate shared business processes with customers and partners across    organizational boundaries using InfoPath Forms Services–driven solutions.

4)    Data accessing is made more simple

     5) Administrators have powerful tools   that ease deployment, management, and system administration .