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

Posts Tagged ‘DotNet’

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 »

Custom Silverlight Navigation with the SP PortalSiteMapProvider

Posted by PANVEGA on June 2, 2009

In this post I wanna explain in a few steps how to develope a custom Silverlight Navitgation for SharePoint publishing sites (Source Silverlight Blueprints on CodePlex)

SharePoint and Silverlight Blueprints on CodePlex were uploaded to include two more Silverlight RTM samples: custom navigation in SharePoint and the colleague viewer. These blueprints provide samples for you to build and explore using Silverlight as an alternate way to develop and integrate powerful user experiences within SharePoint and add rich Internet application functionality to your SharePoint sites. Included in the overall set of samples are a Hello World sample, a Slider sample, and the recently added Custom Navigation and Colleague Viewer samples added

Read the rest of this entry »

Posted in ASP.NET, C#, DotNet, MasterPage, MOSS, Silverlight | Tagged: , , , , , | 1 Comment »

Lists.asmx/GetListItems Accessing the XmlDocument by using the Namespace

Posted by PANVEGA on March 20, 2009

In this short post I am gonna show you how easy it is accessing the List Item values from the GetListItems method of the Lists.asmx Webservice.

  1. Call your GetListItem method
  2. store the XML in a XmlDocument
  3. You have to build a new XmlNamespaceManage
  4. Add the Namespace properties
  5. In this example I wanna access the XmlNode with the first List Item ID

Read the rest of this entry »

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

Query List Items from Lists.asmx Webservice GetListItems

Posted by PANVEGA on March 20, 2009

I created an application where I can retreive a Field ID from a Custon List Item with the Query GetListItem options.

A Query element containing the query that determines which records are returned and in what order, and that can be assigned to a System.Xml.XmlNode object, as in the following example.

  1. Call the GetListItem method
  2. Below you see the parameters from this method
  3. Create a new XmlNode call it “Query”
  4. Create a XmlElement call it “QueryOptions”
  5. Add you custom Query parameters you want
  6. I wanted to query the Item with the ID from the Application Read the rest of this entry »

Posted in C#, DotNet, MOSS, WebServices | 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


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 »

How to implement the SPFeatureReceiver Class to your feature?

Posted by PANVEGA on October 10, 2008


In this post I gonna show you how to implement the SPFEATURERECEIVER class in to your Sharepoint Solution project and give you an example how you can manipulate your Sharepoint Design when activating or deactivating your custom feature. You can use the receiver in almost every custom feature e.g. Webparts, Fieldtypes…

Read the rest of this entry »

Posted in Deployment, MOSS, WebServices | Tagged: , | 2 Comments »

Customize the VariationsLabelMenu UserControl

Posted by PANVEGA on August 6, 2008

The VariationLabelMenu.ascx UserControl gives you the oportunity to switch between the variations on your SharePoint Server. You find the Control in the 12er folder under Program Files~\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES” on your SharePoint 2007 Server. The master page associated with your site contains a small ASP.NET user control named VariationLabelsMenu.ascx that Office SharePoint Server 2007 displays on your pages (Picture), which allows a user to jump to the corresponding page in other variations.

default label menu

default label menu

By changing the value LabelMenuConfiguration in the tag <cms:VariationDataSource id=”LabelMenuDataSource” LabelMenuConfiguration=”2″ Filter=”” runat=”server” /> you can choose between different kind of menue layouts. When you are not satisfied with the possibilities, than add you custom CSS style sheet to the UserControl.

Sometimes you have to uncomment a specific line in the control <cms:VariationsLabelEcbMenu id =”varlabelmenu1″ DataSourceID=”LabelMenuDataSource” DisplayText=”<%$Resources:cms,VariationLabelMenuTitle%>” IsCallbackMode=”true” runat=”server” />.


By default the first language usually index[0] can not trigger when no index changed. Simple add the <asp:ListItem Selected=”True” Value=”Choose Country”/> in the asp:DropDownList and all variations trigger the redirection event to the specific site. In addition you have to set AutoPostBack=”true” to throw an event otherwise nothing happens.

You can hide variations from the navigation by clicking Modify Navigation Settings on the Site Settings page at the Site Collection Level.


<asp:DropDownList ID=”MyDropDown” DataSourceID=”LabelMenuDataSource”
AppendDataBoundItems=”true” DataValueField=”NavigateUrl” OnSelectedIndexChanged=”MyDropDown_OnSelectedIndexChanged” OnLoad=”MyInit” AutoPostBack=”true”
DataTextField=”Displaytext” runat=”server” CssClass=”variation” >
<asp:ListItem Selected=”True” Value=”Choose Country”/>
<script type=”text/C#” runat=”server”>

protected void MyInit(object sender, EventArgs e)

PublishingWeb pWeb = PublishingWeb.GetPublishingWeb(SPContext.Current.Web);

protected void MyDropDown_OnSelectedIndexChanged(object sender, EventArgs e)



Before editing the control make a copy and gib´ve the custom control a new name. For example CustomVariationsLabelMenu.ascx and use it in your master page simply changing the register tag.

OLD <%@ Register TagPrefix=”PublishingVariations” TagName=”VariationsLabelMenu” src=”~/_controltemplates/VariationsLabelMenu.ascx” %>

NEW <%@ Register TagPrefix=”PublishingVariations” TagName=”CustomVariationsLabelMenu” src=”~/_controltemplates/CustomVariationsLabelMenu.ascx” %>

In the last step add the following tag <PublishingVariations:VariationsLabelMenu id=”labelmenu1″ runat=”server”/> in your masterpage to show the standard VariationsLabelMenu.

That ´s all you have to modify. Good luck.

Other Blogs:

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

Integrate an UserControl .ascx into a .aspx Page

Posted by PANVEGA on July 4, 2008


User controls provide a means by which custom graphical interfaces can be created and reused. A user control is essentially a component with a visual representation. As such, it might consist of one or more Windows Forms controls, components, or blocks of code that can extend functionality by validating user input, modifying display properties, or performing other tasks required by the author. Read the rest of this entry »

Posted in ASP.NET, DotNet, UserControls | Tagged: , , , | Leave a Comment »

Custom Workflow Activity combined with InfoPath and XSLT

Posted by PANVEGA on May 4, 2008

In my case I needed a custom workflow activity in order to send a email notification to some users. In addition the workflow triggers when a new InfoPath XSN formular was created. And exactly here was my problem.

In my InfoPath Formular there are some repeating sections which should be transformed via XSLT and CSS in the presented email body.  By default the SP Designer workflow Email activity can not 100% realize the repeating sections. So I developed a custom activity in Visual Studion which links to a specific XSLT file.

InfoPath –> MOSS –> (XSLT, CSS) HTML

Read the rest of this entry »

Posted in DotNet, InfoPath, MOSS, XSLT | Tagged: , , , | Leave a Comment »

Disposable Windows SharePoint Services Objects

Posted by PANVEGA on May 1, 2008

I just ran across this article on MSDN that is a fantastic read. If you do any work where you manipulate SharePoint objects via code, especially SPSite and SPWeb then you must read this. The article is outlines many of the gotcha’s lurking in the object model that you may not be aware of.

Learn the appropriate ways to write your code when using Microsoft Windows SharePoint Services objects so that you can avoid retaining the objects in memory with the Microsoft .NET Framework


Several of the Windows SharePoint Services objects, primarily the SPSite class and SPWeb class objects, are created as managed objects. However, these objects use unmanaged code and memory to perform the majority of their work.

The managed part of the object is small; the unmanaged part of the object is much larger. Because the smaller managed part of the object does not put memory pressure on the garbage collector, the garbage collector does not release the object from memory in a timely manner.

The object’s use of a large amount of unmanaged memory can cause some of the unusual behaviors described earlier. Calling applications that work with IDisposable objects in Windows SharePoint Services must dispose of the objects when the applications finish using them. You should not rely on the garbage collector to release them from memory automatically.

There is also another article that touches on object disposal as well but lists a few other areas to watch for.

If you are seeing performance, memory and stability issues in a SharePoint server that is running custom code then that code should be probably be reviewed while the above articles are fresh in mind.

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

How to develope a custom SharePoint WebService

Posted by PANVEGA on April 20, 2008


For some procedures like, for example, adding the web service as a reference in a visual studio project or using the SP Designer to consume a Webservice, the discovery (.disco) and wsdl files are required. So we have to develope a WS who need to be registert in SharePoint.  We develope a custom SharePoint Webservice with a .disco and .wsdl file.

Because Windows SharePoint Services virtualizes its URLs (for example, http://MyServer/MySite/MySubsite becomes http://MyServer), you cannot use the autogenerated .disco and .wsdl files generated by ASP.NET. Instead, you must create a .disco page and a .wsdl ASPX page that provide the necessary redirection and maintain virtualization.

I recommend you to make a Content Deplyoment of the service. You do not need a solution.xml file, because you do not have a feature deployment in this special case.

At the end you be able to consume the service like any other SharePoint Webservice.


This web service will work with new versions of SharePoint, Office SharePoint Server 2007 and Windows SharePoint Service 3.0. We gonna use the Webservice I developed in my previous post (access SP all Subites recursive). I have used Microsoft articles as a base for this article.

Create an ASP.NET web service in Microsoft Visual Studio 2005. There are two ways to do this. You can develop a web service on the server machine that hosts SharePoint or you can develop it on a remote machine that does not host SharePoint and later deploy the service on the machine that hosts SharePoint. We will discuss the second method in this article.

Add .ASMX file to your project if it’s not already there. This file will contain the programming logic for the web service. Note, you can add programming logic to the markup page as well as the code behind. The choice is yours. Generate a static discovery file (disco) and a Web Services Description Language (WSDL) file. Modify the disco and wsdl files for SharePoint. Deploy the web service files to the SharePoint server. Create a client application or use SP Designer to consume the web service.

My Class is called AllSitesService which returns a XMLNode. This can be a XMLDocument as well. THe method this.getSubSites(domain) iterates through all Subites.

[WebMethod(Description = “Description: Returns a XML Node with all  first level Subsites from the current SP User. <br/> Enter paramter e.g.;)]
public XmlNode getAllFirstLevelSubSites(string domain)
if (!domain.Contains(“http://&#8221;))
domain = “http://&#8221; + domain;
XmlDocument sites = this.getSubSites(domain);
return sites;
catch (Exception ex)
throw (ex);

Read the rest of this entry »

Posted in C#, Delegate Controls, Deployment, DotNet, MOSS, WebServices | Tagged: , , , , , | Leave a Comment »

Custom SharePoint People Picker

Posted by PANVEGA on February 22, 2008

In this example I wanna show you how to customize the SharePoint people picker in a custom webpart with some additional controls.

SharePoint provides a control known as a “people picker” that allows users to search for and select users defined at some specified scope. This control is normally associated with Personnel field in a SharePoint List.

The control is actually called a “PeopleEditor” and is in the ‘Microsoft.SharePoint.WebControls‘ namespace. You will need to add a reference to ‘Microsoft.Sharepoint.dll’ to your project in Visual Studio, which is something you probably already have if you are writing anything that works with SharePoint.

Here’s a list of the people picker properties that can be set ()



The People Picker can only do wildcard searches for AD Windows group names. With any role provider other than the out of the box AD one the role provider lookup is specific to the entire name. For example if you have a group called “Readers” and you enter “Read” in the People Picker search dialog, it will not find your group; if you enter “Readers” it will. The role provider doesn’t provide a good way to do wildcard group search. See “Multiple Auth Providers” for more info. As well Steven Fowler in figuring out a custom membership provider has some great insights, another post People Picker and Custom Membership provider has dev insights on the GetUser() method.

The code creates three controls – a PeopleEditor (from the Microsoft.SharePoint.WebControls namespace), a button and a textbox. The button has an click event that itirates over the users picked in the PeopleEditor and writes them to the text box for instance with a stringbuilder. However you can add any control you are looking for.

First, create a custom webpart in visual studio. Read my post first develope-a-custom-webpart-in-moss.

Read the rest of this entry »

Posted in DotNet, MOSS, WebParts | Tagged: , , , | 2 Comments »