PANVEGA’s Blog

DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Posts Tagged ‘Object Model’

Asccess Denied when accessing Webpart

Posted by PANVEGA on September 8, 2009

In various cases while developing custom web parts or controls for SharePoint we have to use the SPSecurity.RunWithElevatedPrivileges construct to execute some part of the code which needs elevated permissions or which cannot be run with the current user permissions. For example, updating a SPWeb object or SPList object needs elevated permissions.

If you are getting an unauhtorized access exception even after using this block then the reason could be as follows: Read the rest of this entry »

Advertisements

Posted in C#, DotNet, MOSS, Object Model | Tagged: , , , | Leave a Comment »

Accessing webparts in a page using the SP Object Model

Posted by PANVEGA on September 8, 2009

The SPLimitedWebPartManager provides a limited set of Web Part operations that can be performed in the SP object model. It can be accessed by adding the microsoft.sharepoint.dll rference to your class.

In a recent project I had to can the view of some ListViewWebparts in a normal SP Page. The best thing therefore is using the SPLimitedWebPartManager.

Any SharePoint page that includes Web Parts must have an instance of the SPWebPartManager on the page to manage Web Parts. This object tracks which zones each Web Part is in, connection information related to Web Parts, personalization, and page edit mode.” Read the rest of this entry »

Posted in C#, MOSS, Object Model | Tagged: , , | Leave a Comment »

Add a Custom Application.master by using the HttpHandler

Posted by PANVEGA on September 3, 2009

In this post I am going to show you how to apply a custom Application.master to your ShareP0int application by using the IHttpModule. My approach was to create an “HttpHandler” that simply would override the “Page_PreInit” method and change the master page.

Of course you have to create a solution in order to deploy your CustomApplication.master to the 12 Hive folder (e.g. LAYOUTS\CustomMaster\CustomApplication.master). The path to your master page in your 12 Hive and  in the code below should be correct.

page.MasterPageFile = “/_layouts/CustomMaster/CustomApplication.master”;

After you activated the feature and you want to load a page setting for instance, Sharepoint should now apply your custom master. Read the rest of this entry »

Posted in C#, DotNet, MasterPage, MOSS, Object Model | Tagged: , , , | Leave a Comment »

Using SPWebConfigModification within a Feature Receiver

Posted by PANVEGA on September 2, 2009

Sometimes when developing moduls for SharePoint you have to register these modules in your application web.config. You can easily do this by using the SPWebConfigModification class in combination with a feature receiver.

This class holds modifications that are made to the web.config.

Quite often I have to make some changes in the web.config files of the web applications where my solutions are to be deployed. Manifest.xml files of Sharepoint Solutions helps us with this task providing us with some easy ways to alter the web.config files, unfortunately, we are limited at registering safe controls and alter security policies which sometimes is not enough. Read the rest of this entry »

Posted in C#, Deployment, MasterPage, MOSS, Object Model | Tagged: , , , , | 1 Comment »

How to retrieve Sites and Pages from the SiteMapProvider recursively

Posted by PANVEGA on April 8, 2009

In this short post I gonna show you how to retreive  a SharePoint SiteMapProvider here CurrentNavSiteMapProvider (LeftNavBar) in your MasterPage and create a XML file where you gonna write the XmlNodes in a hierarchigal structure. You can use the XML for instance to add the control into your MasterPage and parse the Navigation Tree with Silverlight, JavaScript or Flash in order to get your custom animated SharePoint Navigation.

Sharepoint is going to build you a sitemapprovider based off your logical architecture of your site. So, if you site has a root site and it has children and it’s children have children – then the sitemapprovider it creates for you will look like that.

Read more about SiteMapProvider and how to customize in one of my previous post:

https://panvega.wordpress.com/2008/04/18/customize-the-sharepoint-navigation-aspmenu

Provides PortalSiteMapNode objects that represent a merging of the Windows SharePoint Services 3.0 SP Navigation store and dynamic site structure, including sites and pages.

 Read the rest of this entry »

Posted in Flash, MasterPage, MOSS, Object Model, SideMapProvider, Silverlight, XML | Tagged: , , , , , , | 1 Comment »

Introduction in Custom WF Activities

Posted by PANVEGA on January 20, 2009

Microsoft Office SharePoint Designer 2007 allows non-developers to create custom workflows in a straightforward way by using the workflow designer it provides. During the process, the user “glues” together different activities that represent the steps for the workflow. There are numerous activities one can use and the list is extensible. Developers can use Microsoft Visual Studio 2005 to build additional activities and deploy them, so that they are available in Office SharePoint Designer 2007.

My example in the post extendes the default out of the box Activity in the SP Designer (Copy List item). In the default activity you can only copy an item in the same site. I added a new attribute DestinationListUrl which copies the select item from the root list by using the SP Object Model to the destination list in an other site collection.

copyitem

On Codeplex you find some useful custom SP Activities Read the rest of this entry »

Posted in Administration, C#, Deployment, DotNet, MOSS, Object Model, SPDesigner, Workflows, XML | Tagged: , , , , , , , , | Leave a Comment »

How to add a SPFeatureReceiver to a Custom ListInstance?

Posted by PANVEGA on January 19, 2009

In reference to my previous post about binding a Custom ContentType to a new ListInstance, I wanna solve this issues belowe with a SPFeatureReceiver class in Visual Studio.

https://panvega.wordpress.com/2009/01/19/how-to-bind-a-customcontenttype-to-a-listinstance-feature

https://panvega.wordpress.com/2008/11/05/how-to-develope-a-custom-sp-eventreceiver

First off the default view of your list does not contain those custom columns. When you select the item you will of course see all of your columns but they aren’t listed in the default view. Secondly the default content type for the list is still available to the user. In the case of a generic list the “Item” content type is still present. So when a user enters a new item they are able to select Item or your custom content type. This may not be desirable. Also if you are using the API to insert a new item into the list it will use the list’s default content type instead of the one you may be expecting. Once again this may not be desirable.

To overcome these restrictions we’re going to create a generic feature receiver that can be reused on any implementation using this technique. Read the rest of this entry »

Posted in C#, Custom Content Types, Deployment, DotNet, Event Receivers, MasterPage, MOSS, Object Model, Site Definition | Tagged: , , , , , , , , | Leave a Comment »

How to modify the Userprofile´s QuickLinks (MyLinks) with the SP Object Model.

Posted by PANVEGA on November 25, 2008

In this post I wanna explain how to access the UserProfile´s QuickLinks (MyLinks) Sharepoint Personal Sites with the SP Object Model.

  • The best way is to create a custom WebPart with the Visual Studio VSTO template.
  • Add all appropriate references to your project
  • Add your custom code
  • Deploy the Webpart Read the rest of this entry »

Posted in MOSS, My Links, Object Model | Tagged: , | 2 Comments »

Retreive recursive all SP Subwebs with current User Permission

Posted by PANVEGA on November 20, 2008

As an alternative to programming against the SharePoint web services you can use the SharePoint object model. The object model can be used when the application will run on the server where SharePoint is installed (such as a console or WinForm application) or in assemblies that are run within a site (such as a Web Part or Webservices).

One of the great things about the object model is that it is security trimmed, so you can usually just ask for items that the user has permissions for. However, there may be items that the user can access but the user still doesn’t have access to perform a specific task– which is a great reason to check for permissions before attempting an operation

Situation:

I need a way to retreive a existing Subwebs Sites from SharePoint how the current User has the rights to access the site. This information should be used to store the items in a XMLDocument and returns the content to a custom SharrePoint WebService method. Read the rest of this entry »

Posted in DotNet, MOSS, Object Model | Tagged: , | Leave a Comment »