Posts mit dem Label SharePoint werden angezeigt. Alle Posts anzeigen
Posts mit dem Label SharePoint werden angezeigt. Alle Posts anzeigen

Dienstag, 19. Februar 2013

Debugging SharePoint

 

To know which w3wp Process you need to attach just use this command:

C:\wondows\System32\inetsrv\appcmd list wp

Found here: Attaching specific W3WP Worker Process in SharePoint Custom Code Debugging.

Dienstag, 24. April 2012

Central Administration prompts for password

Before you start digging for complex reasons try this one: Add the Central Administration site to the Local Intranet Sites on the Application Server, this should solves the problem in most of the cases.

Donnerstag, 29. Dezember 2011

How to get Name and other Information of the provider in the consumer WebPart

I needed to display the name of the provider webpart in a consumer WebPart when working with WebPartConnections. 

Here the code to access provider Information from the consumer WebPart:

SPWeb myWeb = SPControl.GetContextWeb(Context);
SPLimitedWebPartManager webPartManager = myWeb.GetLimitedWebPartManager(this.Page.Request.FilePath, PersonalizationScope.Shared);


foreach (SPWebPartConnection connection in webPartManager.SPWebPartConnections)
{
    if(writer != null)
        writer.Write("Provider: " + connection.Provider.Title
+ " - Consumer: " + connection.Consumer.Title + "<br />");
}


Mittwoch, 21. Dezember 2011

Error when placing a TextBox inside a LayoutsPageBase

I was developing an application page that inherits from the LayoutsPageBase. 
In this page I added a user Control in which I added A TextField and a Button. Here is the code for that part:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ExportApplicationSettingsUserControl.ascx.cs" Inherits="ListItemExport.ControlTemplates.ListItemExport.ExportApplicationSettingsUserControl" %>
<asp:TextBox ID="exportTemplate" runat="server"></asp:TextBox>
<br />
<asp:Button ID="saveButton" runat="server" onclick="saveButton_Click" Text="Button" />

When Executing this code I got following error message:

Control 'ctl01_exportTemplate' of type 'TextBox' must be placed inside a form tag with runat=server.

So I added the form tag around my form elements like this:

<form id="myForm" runat=server></form>
<asp:TextBox ID="exportTemplate" runat="server"></asp:TextBox>
<br />
<asp:Button ID="saveButton" runat="server" onclick="saveButton_Click" Text="Button" />
</form>

This time a got following error message:

A page can have only one server-side Form tag.

It came out that the masterpage already had a form tag. I tried to delete the form tag from the masterpage or to include other masterpage, but nothing helped. There were always new errors appearing.
Finally I found the solution for my problem. It appeared that this was simply a bug. The solution was to add following empty method to the application page code behind:


public override void VerifyRenderingInServerForm(Control control){}

Don’t forget to delete the added form tag in the application page. And don’t make any changes on the masterpage.
This solved the problem. Thanks to this Post 

Create xml file from string and downloading it with save dialog

I needed to create an XML programmatically and then to send it to the user to download. For this purpose I created a Page that is called from a customAction. Here is the code for the xml downloading part.
Aspx:
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExportApplication.aspx.cs" Inherits="ListItemExport.Layouts.ListItemExport.ExportApplication" Debug="true" %>

Code Behind:
namespace ListItemExport.Layouts.ListItemExport
{
    public partial class ExportApplication : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e){
            base.OnLoad(e);
            String xmlString = "<xml><test>testvalue</test></xml>";

            String listId = Request.Params["listId"];
            String itemId = Request.Params["itemId"];

            XmlDocument xDoc = new XmlDocument();
            xDoc.LoadXml(xmlString);

            MemoryStream xmlStream = new MemoryStream();
            xDoc.Save(xmlStream);
            Response.Clear();
            Response.AppendHeader("Content-Disposition","attachment; filename=test.xml");
            Response.ContentType = "text/XML";
            Response.BinaryWrite(xmlStream.ToArray());

        }
    }
}

Freitag, 16. Dezember 2011

Sharepoint WebPart Lifecycle Events

When developing SharePoint WebPart you absolutely need to know the WebPart Lifecycle Events.

I found this great description on Phil Harding site. Here you can find the original Post: Sharepoint WebPart Lifecycle Events

Dienstag, 13. Dezember 2011

How to get SharePoint List ID not HTMLEncoded

When you try to get a List ID in SharePoint you will always go to Library Settings and get it from the URL. There will be something like this:

listedit.aspx?List=%7B618C96DB%2DE1C5%2D4C7D%2D9B69%2D2AEB4702008D%7D

Problem here is, that you need to replace different Strings (%7B, %7D, %2D) this is not really a problem but it is a waste of time.

In the List Settings (or library Setting) just click on "Information management policy settings". Here you can get your clean decoded List ID from the URL

Example:

List={618c96db-e1c5-4c7d-9b69-2aeb4702008d}

Mittwoch, 7. September 2011

How to change the order in the SharePoint Foundation alternative SPSiteMapProvider

I was trying to improve the navigation for a customer without investing to much in money and time. I found a solution discribed in this blog:
Easy and Simple SharePoint 2010 Dropdown Navigation bar that works no scripts, no web.config, works on hosted providers

In summary: go to the masterpage and replace this part:
<SharePoint:AspMenu
      ID="TopNavigationMenuV4"
      Runat="server"
      EnableViewState="false"
      DataSourceID="topSiteMap"
      AccessKey="<%$Resources:wss,navigation_accesskey%>"
      UseSimpleRendering="true"
      UseSeparateCss="false"
      Orientation="Horizontal"
      StaticDisplayLevels="2"
      MaximumDynamicDisplayLevels="1"
      SkipLinkText=""
      CssClass="s4-tn"/>
    <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
        <Template_Controls>
            <asp:SiteMapDataSource
              ShowStartingNode="False"
              SiteMapProvider="SPNavigationProvider"
              id="topSiteMap"
              runat="server"
              StartingNodeUrl="sid:1002"/>
        </Template_Controls>
    </SharePoint:DelegateControl>

with this:
<SharePoint:AspMenu
 ID="SPSiteMapProvider"
 Runat="server"
 EnableViewState="false"
 DataSourceID="SiteMapDataSource1"
 AccessKey="<%$Resources:wss,navigation_accesskey%>"
 UseSimpleRendering="true"
 UseSeparateCss="false"
 Orientation="Horizontal"
 StaticDisplayLevels="2"
 MaximumDynamicDisplayLevels="3"
 SkipLinkText=""
 CssClass="s4-tn"/>
 <asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1"/>
<SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
 <Template_Controls>
 <asp:SiteMapDataSource
 ShowStartingNode="False"
 SiteMapProvider="SPSiteMapProvider"
 id="topSiteMap"
 runat="server"
 StartingNodeUrl="sid:1002"/>
 </Template_Controls>
</SharePoint:DelegateControl>
Unfortunately this Navigation provider sort the Items using ASCII order. He don't care about the order defined in the ToNavigationConfiguration interface.

So how can I sort the sites anyhow? Just add whitespaces to the title of the Web that you want to be on the first. Example:

Pages with the titles "First", "Second", "Third", "Fourth" and "Fifths" will be shown in this order:
"Fifths", "First", "Fourth", "Second", "Third"
To get them in the right order change the name to this:
"    First", "   Second", "  Third", " Fourth" and "Fifths"

And don't worry the whitespaces are trimmed in both the Navigation and the Page title.

It's not the most elegant way, but it works.

Enjoy and share