about 'passion for coding'

I write about sharp, .net, SharePoint, etc.

How to Modyfied MySite Navigation Into Left Navigation Bar (QuickLaunch)

One of managers asked me to move MySite navigation to the quick launch navigation on the left side. He asked if I would make this, whether it would be a very difficult and requires a lot of time. Someone else told him that we cannot do it - it is to much time expensive. The reality is this is very easy.

You only need two things to do:

SharePoint DateTimeControl and Custom Forms

Micrtosoft.SharePoint.WebControls.DateTimeControl does not show properly on your own forms. The problem you could get is displaying popup calendar does not look properly. This appears when you use subsites.

TrayBar - Status Bar in Cocoa (NSStatusBar)

I am .net programer for several years. I was looking for something new, new challenges. Becase of this (and of course willingness to try new platform) I decided to buy my first mac and started realize my ideas. First application i have installed was XCode and the party has began ;) Ok, let’s back to the main topic - how to add your own icon or text to the system status bar, which is Mac OSX equivalent of MS Windows’ tray bar or tray menu. We want to create icon with menu options: start, stop and quit. Additionally we want that after click start menu item icon was replaced by time counter (like on the image below).

status bar menu with open menu items

Strongly-typed Resources With VS2010 SharePoint Templates

SharePoint project template from new VS2010 are very nice and convenient. In 1 - 2 simple steps we can add resource file. Number of steps depends on place where we want to deploy it. This post will describe how to add resource files to SharePoint solution and how use it as strongly typed without trouble with deploying it.

ObjectDataSource on SharePoint Pages

One of my friend ask me why he has problem using ObjectDataSource with SharePoint pages.

He was using ObjectDataSource in many ASP.NET Web Application and has not any problems. Imagine his surprise when he saw this error:

1
2
3
4
5
6
7
8
9
10
11
System.InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'odsDepartment' could not be found.
    at System.Web.UI.WebControls.ObjectDataSourceView.GetType(String typeName)
    at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect( DataSourceSelectArguments arguments)
    at System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)
    at System.Web.UI.WebControls.ListControl.PerformSelect()
    at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound()
    at System.Web.UI.WebControls.ListControl.OnPreRender(EventArgs e)
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Control.PreRenderRecursiveInternal()
    at System.Web.UI.Control.PreRe...

In ASP.NET Web Application is enough when you set TypeName property with yourNamespace.yourClassName, but on the SharePoint pages that is not enough. You can select one of the following options:

  1. add to the typename properties in aspx file full name of your assembly.
  2. 1
    
    <asp:ObjectDataSource ID="odsDepartment" TypeName="yourNamespace.DepartmentLogic, $SharePoint.Project.AssemblyFullName$" SelectMethod="Select" OnObjectCreating="GetDepartments" OnObjectDisposing="ReturnDepartments" runat="server" />
    
  3. add your assembly to the assemblies in the web.config of your SharePoint application.
  4. 1
    2
    3
    4
    5
    6
    7
    
    <compilation batch="false" debug="false">
        <assemblies>
           ...
           <add assembly="yourAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e0e1ddb7afa0d474"/>
        </assemblies>
        ...
    </compilation>
    

Customizing SearchBox

Have you ever heard about DelegateControl ? If not read this.

You do not need create new master page for customizing your SharePoint sites. Default.master contains several delegate controls:

  • AdditionalPageHead
  • SmallSearchInputBox - is using to change search box at the top right corner of the sp page
  • GlobalSiteLink0
  • TopNavigationDataSource
  • PublishingConsole

Using it you are able to inject to the page every control you want. AdditionalPageHead delegate control is the most frequently use, because it is the one that gives you possibility to add more than one control (AllowMultipleControls=”true”). It is added in tag, and it could be using for injection many curious things (js files, controls for managing ribbon menu, etc).

How to use delegate control on the example of search box.

  • create feature (delegate control could be use with any feature scope you need)
  • create control definition and add it to feature. Of course, it need to be added inside element manifest.
1
2
3
<Control Id="SmallSearchInputBox" 
         ControlSrc="~/_controltemplates/your_path/search.ascx" 
         Sequence="10" />

You could also use:

1
2
3
4
<Control Id="SmallSearchInputBox"
  ControlClass="yourNamespace.yourClassName"
  ControlAssembly="$SharePoint.Project.AssemblyFullName$"
  Sequence="10" />
  • create your control in controltemplates mapped folder your_path/ search.ascx which could be normal base usercontrol with basic html. For instance script tag or
1
<a href="advancedSearch.aspx">Advanced search</a>
  • deploy you feature to the serwer
  • activate feature and be happy with the results ;)

For more information you can read this.