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

Archive for the ‘MOSS’ Category

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 »


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 »

Custom SharePoint Page Counter

Posted by PANVEGA on September 7, 2009

In this post I show you how easy it is to develope a custom Page Counter Webpart in Visual Studio.

In one of my older post I explaid how to add Counter Web Component to your page by using the SP Designer. However this approach has some disadvantages.

Steps to do:

  1. Create a new Custom Field for instance PageCounter
  2. Add this custom field to your Page ContentTypes by using a FeatureReceiver Class
  3. Create a Webpart project
  4. Access the Pages List and parse all pages.
  5. increment the custom PageCounter filed
  6. Incremt just in Publish Level Mode
  7. do a item and list update Read the rest of this entry »

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

SharePoint Feature Activation Dependences

Posted by PANVEGA on September 7, 2009

A XML element that you can add to our FEATURE.XML is called, “ActivationDependencies”. When WSS activates a feature that defines activation dependencies, it automatically activates any dependent feature that has already been activated.

Here is an example of an activationdependence for the publishing feature.

Read the rest of this entry »

Posted in Deployment, MOSS, XML | 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 »

Failed to load viewstate Error

Posted by PANVEGA on August 27, 2009

When I developed a Custom Webpart I had to build some dynamic added ASP Control (DropDownList etc.) during and after postback. Then I received the follwing error message during the Webpart was changing the Controls.

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.


For example, if I dynamically add a textbox to a page, that textbox MUST exist before the viewstate for the page is loaded after a postback. This is because the when the page attempts to load viewstate, the control hierarchy must match the control hierarchy that existed when viewstate was originally created. Read the rest of this entry »

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

CSS Styles for your GlobalLinks in the Core.css

Posted by PANVEGA on July 13, 2009

So usually Mozillas Firebag or IE´s DeveloperTool bar are perfect for editing the CSS Styles for your SharePoint pages.  But sometimes there are some fairly hard styles to catch though, even with the assistance of on of these add-ons. Within your SharePoint site you want to customize the colors or background a little.

Generally, styles I primarily use to change the main elements of Site Actions are as follows, though a quick search for “ms-menuUI” in core.css will lead you to the quick realization that this list is not near exhaustive:

DO NOT MODIFY THE CORE.CSS. But the classes into a seperate CSS file and reference it in your MasterPage. Read the rest of this entry »

Posted in CSS, MasterPage, MOSS | Tagged: , , | Leave a Comment »

Custom SharePoint TreeView Navigation with CodeBehind

Posted by PANVEGA on July 12, 2009

In this short post I gonna explain how easy it is to customize your tree view navigation. In one of my prevois post I explaind how to customize your QuickLaunch Left Navigation in your MasterPages ASP:Menu properties. However the confiuration at this point was limited. I needed a dynamic 3 Level with an automatic expaned and collapse menu.

Read my previous post first:

You can solve this problem by using asp:TreeView control: Read the rest of this entry »

Posted in C#, DotNet, MasterPage, MOSS | Tagged: , , , | 3 Comments »

Receive a detailed Error Message from a SP MasterPage

Posted by PANVEGA on July 9, 2009

By default you receive an “An unexpected error has occurred” in your MasterPage when you try to make any special changes. However this gives you not the information you expect when customizing your Master Page.

What to do:

Enabling stack traces and disabling custom error pages in web.config is a great way to help you diagnose the specific problems.

You can do this by setting <customErrors mode="Off" /> in web.config and

the CallStack="true" property in the <SharePoint><SafeMode> tag in web.config.

More Information about custom Error Messages:

Posted in Administration, MasterPage, MOSS | Tagged: , , | Leave a Comment »

Deployment for a Custom SP PageLayout

Posted by PANVEGA on June 25, 2009

In this post I gonna explain in a few steps how to build a SharePoint Feature for a PageLayout. To do this, I needed to create a new page layout based on an existing layout, make this part of a feature and pull in all the bits and pieces necessary to deploy this as a feature.

First I copied a default PageLayout (Welcome Page) with a Fields from this Content Type.The Content Type Group is the default Page Layout. To do This opnen the _catalogs with the SP Designer. Now you have the basic aspx files you will modify and put back into SharePoint as a feature. Open the aspx page in an appropriate editor. Make the appropriate modifications and save the file.

Read the rest of this entry »

Posted in Deployment, MasterPage, MOSS, PageLayout, SPDesigner | Tagged: , , , , | 1 Comment »

How to add a HIT COUNTER to a page

Posted by PANVEGA on June 22, 2009

In this post I wanna describe how to add a Hit Counter Component by using Microsoft Office SharePoint Designer.

Attention: this description below is just useful when you creat a new aspx page or prepare your MasterPage for example. If you try adding the Component to a Page Template, the Page instances refernce to the same central component. That mean the counter does not start from zero when you create a new page from a template. It goes on incrementing the counter from the first page you created. That means every page instance shows the same page or hit counter.

In my next post I gonna explain how to solve this problem. Read the rest of this entry »

Posted in MOSS, SPDesigner | Tagged: , | 2 Comments »