UserControl error could not load type in SharePoint

by Bas Hammendorp 18. February 2010 04:59

So I was building my user control in SharePoint, no rocket sience I thought. When I opened my default.aspx page with the user control, the error 'could not load type ...' is shown. After some struggling and experimenting, I found out that my dll which was deployed in the GAC needed to be moved into the BIN folder.

Maybe there is a good explanation for this, but I have no clue ;) So my conclusion is to deploy the ASCX / ASPX code behind assemblies in the BIN folder of the web application.

Have fun!

Update 4 March 2010: Also when you get the error 'Could not load type ...' from a code behind file in for example a masterpage, try to move the assembly to the BIN folder

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

asp.net | Sharepoint

Draft Item Security in the list schema file

by Bas Hammendorp 6. January 2010 05:21

I was looking for an option to add the 'Draft Item Security' in the list schema file. This can be changed in the UI when you click the document library settings -> versioning settings. The possible options of 'Who should see draft items in this document library?' are:

  • Any user who can read items (DEFAULT)
  • Only users who can edit items
  • Only users who can approve items (and the author of the item)

If you want this setting automatically in you document library, you must add the DraftVersionVisibility attribute to your List node in the schema.xml. The value must be an integer which has the next options:

  • 1 = Only users who can edit items
  • 2 = Only users who can approve items (and the author of the item)
  • All other values = Any user who can read items (DEFAULT)

So for example :

<List Title="My new document list" DraftVersionVisibility="1">

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

Narrow search results to one type

by Bas Hammendorp 21. December 2009 11:22

Lat's say you want to show the results of your own document content type, but when you search all possible options show up. What you can do then is to add a rule to your search scope.

Go to site settings > Scopes > Click on your custom scope

The click on the 'add rule' option and in the next screen choose the 'Property Query' option. Then choose the 'contentclass' option in the 'Property Query' section. As a value for this property you must fill out the value STS_ListItem_<your list template ID>. For example if you used the template ID 10150 in your list feature, the contenclass must be equal to STS_ListItem_10150. The behaviour option must be set to Require.

After recrawling, the search result is narrowed to only your list items.

Currently rated 3.0 by 5 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

In my ONET.XML module I wat two views on one list

by Bas Hammendorp 21. December 2009 07:56

In a recent project I wanted to show two views of one list. The problem is that by default the title of the List node is copied into title[1] and title[2]. To solve this, you must include the <webpart> in the view element. So I opened the ONET.xml of the site definition. In the Configuration/Lists section I added my list feature:

<Lists>
 <List FeatureId="&lt;myGuid>" Title="My List" Type="12345" Url="Lists/MyList" />
</Lists>

Then in the Modules/Module/File section in the ONET.xml we need to add the View element:

<View List="Lists/My List" BaseViewID="1" WebPartZoneID="Header" WebPartOrder="1" Type="HTML">
 <![CDATA[
  <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
   <Title>My first custom title</Title>
   <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
   <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
  </WebPart>
 ]]>
</View>


<View List="Lists/My List" BaseViewID="2" WebPartZoneID="Header" WebPartOrder="2" Type="HTML">
 <![CDATA[
  <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
   <Title>My second custom title</Title>
   <Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
   <TypeName>Microsoft.SharePoint.WebPartPages.ListViewWebPart</TypeName>
  </WebPart>
 ]]>
</View>

As you can see, in the CDATA you can find an element Title which you can use for your own custom title!

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sharepoint

Just some LINQ examples

by Bas Hammendorp 17. December 2009 03:30

I was working with LINQ (which is cool) and I found this site: http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx

Always nice to have a good reference site for examples.

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

linq

Enable list versioning in the schema.xml

by Bas Hammendorp 15. October 2009 05:01

If you want to enable versioning for your Sharepoint list, you can do this is the schema.xml of your list. You must add the next attributes in the List node:

VersioningEnabled="TRUE" MajorVersionLimit="0" MajorWithMinorVersionsLimit="0"

It's as easy as that, but always be carefull not to enable this for all lists!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Sharepoint

Show all items of the Sharepoint list item in itemstyle.xsl

by Bas Hammendorp 28. September 2009 09:03

If you want to know which attributes and value are available in a sharepoint list (item), you can add the following code in the itemstyle.xsl:

<xsl:for-each select="@*">
Item: <xsl:value-of select="name()"/>
Value: <xsl:value-of select="."/><br/>
</xsl:for-each>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Sharepoint | XSL

Get current and last row position in itemstyle.xsl

by Bas Hammendorp 23. September 2009 10:01

I was looking for a solution so that I could use one table in my ItemStyle. I have created my custom item style and I don't want to create a table with each item, so I need the current row and the last row. If I use <xsl:value-of select="position()" /> each value is 1, so that will not do the trick. What should I do? Well here's the answer, first edit the 'ContentQueryMain.xsl' (in the Style Library). Search for the next template:

<xsl:template name="OuterTemplate.CallItemTemplate">

Then replace the complete template with the next code:

<xsl:template name="OuterTemplate.CallItemTemplate">
    <xsl:param name="CurPosition" />

    <!--
      The LastRow parameter is used in style "MyStyle".
    -->
    <xsl:param name="LastRow" />

    <xsl:choose>
      <xsl:when test="@Style='NewsRollUpItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="EditMode" select="$cbq_iseditmode" />
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="@Style='NewsBigItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="CurPos" select="$CurPosition" />
        </xsl:apply-templates>
      </xsl:when>
      <xsl:when test="@Style='NewsCategoryItem'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="CurPos" select="$CurPosition" />
        </xsl:apply-templates>
      </xsl:when>

      <!--
              Pass current position and lastrow to the MyStyle itemstyle.xsl template
      -->
      <xsl:when test="@Style='MyStyle'">
        <xsl:apply-templates select="." mode="itemstyle">
          <xsl:with-param name="CurPos" select="$CurPosition" />
          <xsl:with-param name="Last" select="$LastRow" />
        </xsl:apply-templates>
      </xsl:when>

      <xsl:otherwise>
        <xsl:apply-templates select="." mode="itemstyle">
        </xsl:apply-templates>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

Then look for the <xsl:template name="OuterTemplate.Body"> code in the ContentQueryMain.xsl and insert the lastrow parameter:

<xsl:call-template name="OuterTemplate.CallItemTemplate">
  <xsl:with-param name="CurPosition" select="$CurPosition" />
  <!-- Insert the LastRow parameter. -->
  <xsl:with-param name="LastRow" select="$LastRow"/>
</xsl:call-template>

When this is done, you can use the parameters:

<xsl:param name="CurPos" />
<xsl:param name="Last" />

in you custom ItemStyle template. These can be used to show the table start (if $CurPos=1) and table end tag (if $CurPos=$Last) in your item list.

Hope this helps you as much as it did me ;)

Thanks to the post of Paul Galvin!

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Sharepoint | XSL

Starting points for Sharepoint Development

by Bas Hammendorp 1. September 2009 02:27

This post may not be usefull for everybody, but I would like to sum up some interesting starting points for sharepoint development:

If you have other good suggestions, let me know! I will try to update this post everytime I find some interesting sites.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Update the title of the welcome page in sharepoint and c#

by Bas Hammendorp 31. August 2009 05:23

I was looking for a way to update the page title of my welcome page in c# and I got to the following example:

SPWeb web = SPContext.Current.Site.OpenWeb();
PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(childWeb);
SPFile defaultPage = pubWeb.DefaultPage;

defaultPage.CheckOut();
defaultPage.Update();

defaultPage.Item["Title"] = "My title";
defaultPage.Item.Update();

defaultPage.CheckIn("My comment");
defaultPage.Update();

Have fun!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C# | Sharepoint

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

My name is Bas Hammendorp, I work as an Enterprise Engineer at PGGM. My specialties are ASP.NET, C#, SQL and Sharepoint 2007.

Google ads