CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: SharePoint 2010

The original Visual Web Part template is missing in Visual Studio 2012

Today I encountered a weird issue, the classic Visual Web Part template was gone in Visual Studio 2012. When I created a Visual WebPart, a webpart was created with a generated .g.cs file, like the sandboxed visual webparts. I am not exactly sure why it happened. According to the MSDN guide Creating Web Parts for SharePoint, the structure of Visual Webparts should be the same as in Visual Studio 2010. It could have happened after I installed the power tools.

However, if someone runs into the same issue, here is the solution:

Copy this zip file from a computer with VS2010 installed:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\SharePoint14VisualWebPart.zip

Unpack it.

Edit SharePointVisualWebPart.vstemplate. Change the assembly line so it references to the Version 11:

<Assembly>Microsoft.VisualStudio.SharePoint.ProjectExtensions.Wizards, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>

After that copy the directory SharePoint14VisualWebPart to these two locations on your computer with Visual Studio 2012 installed.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplates\CSharp\SharePoint\SharePoint14\1033\
C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ItemTemplatesCache\CSharp\SharePoint\SharePoint14\1033\

Just to be safe, save the SharePoint14VisualWebPart (which have the same name) by appending “.bak” to the name.

If you don’t have an access to a VS2010 computer, I have saved the template for you on github.

Advertisements

The right URL regardless AAM zone

For a while ago my colleague gave me a nice tip of getting the right absolute url regardless sharepoint zone in Alternate Access Mappings. I want to share it, because it is brilliant:

var url = SPUtility.AlternateServerUrlFromHttpRequestUrl(new Uri(value)).AbsoluteUri;

$ in cmssitemanager.js conflicts with $ in jQuery

In SharePoint 2010 if CMSSiteManager.js library is loaded besides jQuery, then much of stuff stops working. The reason is that the dollar sign ($) is used in cmssitemanager.js as well which conflicts with jQuery. Mostly it appears on pages where you load jQuery and have an image library with thumbnails. To avoid this, just replace all $ with jQuery in your custom scripts. A more crazy situation is when avoiding $ isn’t enough. It is when you load jQuery to page head automatically on all pages. The Asset picker (AssetPortalBrowser.aspx) invokes $ itself and gets with jQuery in conflict without you write a single line of custom javascript code. You usually get the following error:

Uncaught TypeError: Cannot set property 'display' of undefined


Or in IE:

Unable to set value of the property 'display': object is null or undefined

The solution

I found a good solution in Brad Curtis’ blog. Run in your script:

jQuery.noConflict()

Brad Curtis creates an additional script file. But it is okay to have this line in your javascript file, so long you load this every time jQuery is loaded. So put this before your javascript code:

// this puts jquery into no conflict mode 
//which will remedy conflicts caused by jQuery when used
// with certan publishing features
jQuery.noConflict();
Important

If you use jQuery.noConflict, the dollar sign ($) is not available anymore! So replace all $ with jQuery. (Unless it is inside modules… another time about that…)

Update 2013-12-06

Thanks to Steve’s comment. Please consider to use closures where you pass jQuery as a parameter

(function($) {
  //do your jQuery stuff
  $(".selector").show();
}
)(jQuery);

Please, keep in mind, the $ in cmssitemanager.js has nothing to do with jQuery, unfortunately it uses the same variable name. The issue applies for SharePoint 2013, too.

Add Comments column to your sharepoint list

If you have used Issue tracking list template in SharePoint you must have marked that the comments are added and marked with author name and datetime. It is handy to have these micro “discussion boards” on items. The comment-formed communication can help to fine-tune task definitions. By the way, have you seen Trello?

So the question is how we can create this column in other lists? Here is a little tutorial how to create “append-only comments”, as they are called:

Go to your list and enable versioning

Add “Append-only comments” column from existing site columns

(In Swedish this Site Column is called: “Lägg endast till kommentarer”)

Go ahead and write comments

 

Add append-only comments in XML

 

A simple Log for ULS

Here is a simple log which has been inspired of Android Log. It logs to ULS which you can open with ULSViewer, SharePoint Log Viewer.

using System;
using Microsoft.SharePoint.Administration;

namespace Contoso.Intranet.Portal.Utilities
{
    public class Log
    {
        private static readonly string _CATEGORYNAME = "CONTOSO";
        private static readonly SPDiagnosticsCategory _ERROR_CATEGORY = 
              new SPDiagnosticsCategory(_CATEGORYNAME, TraceSeverity.Unexpected, EventSeverity.Error);
        private static readonly SPDiagnosticsCategory _WARNING_CATEGORY = 
              new SPDiagnosticsCategory(_CATEGORYNAME, TraceSeverity.High, EventSeverity.Warning);
        private static readonly SPDiagnosticsCategory _VERBOSE_CATEGORY = 
              new SPDiagnosticsCategory(_CATEGORYNAME, TraceSeverity.Verbose, EventSeverity.Verbose);
        private static readonly SPDiagnosticsCategory _INFO_CATEGORY = 
              new SPDiagnosticsCategory(_CATEGORYNAME, TraceSeverity.Medium, EventSeverity.Information);

        private static void WriteTrace(SPDiagnosticsCategory category, string message, string trace)
        {
            SPDiagnosticsService.Local.WriteTrace(0, category, category.DefaultTraceSeverity, message, trace);
        }

        public static void Error(Exception ex)
        {
            WriteTrace(_ERROR_CATEGORY, ex.Message, ex.StackTrace);
        }

        public static void Warning(string message)
        {
            WriteTrace(_WARNING_CATEGORY, message, "");
        }

        public static void Verbose(string message)
        {
            WriteTrace(_VERBOSE_CATEGORY, message, "");
        }

        public static void Info(string message)
        {
            WriteTrace(_INFO_CATEGORY, message, "");
        }

    }
}

A possible improvement can be a custom Area. See an example of ThorstenHans on Github: CustomLogger.cs

EDIT: I found an interesting article: How to log to the SharePoint ULS Logs: Clean Debugging and Error Logging broken down into steps written by Philip Stathis.

Sharepoint Manager 2010

Ett ytterligare grym verktyg från codeplex-lägret: Sharepoint Manager.

spm

Förenkla skapandet av utvecklingsmiljön till SharePoint 2010

Jag är fortfarande i mitt sökande efter den perfekta (för mig) utvecklingsmiljön för SharePoint 2010. Fram tills nu har jag arbetat med en virtuell (VMware) maskin som kollegor till mig har konfigurerat. Men jag vill ha kunskapen att göra det själv. Än så länge har jag bara stött på procedurer som är relativt långdragna, fram tills idag. Se på videon på sidan jag länkat nedan. Jag ska testa det och sen förhoppningsvis komma med resultat här.

Mitt mål är att lätt komma igång med en maskin som körs som VHD eller native dualboot. Men jag börjar med en virtuell VMware maskin.

Ett dygn senare: Igår lät jag skriptet köra (utan config ändringar) och efter många timmar är allt installerat och klart. Dock trailversioner. Men gör man det en natt efter 2 veckor eller när trailen är slut, då kan man börja på en ny maskin igen. Jag gillar skarpt detta skript! Ännu bättre blir det nog när man konfigurerar det att fixa en VHD. Kommer mer om det när det är testat!

Länksamling
Film från Channel 9
Ladda ner Scriptet här

Skriptskaparnas bloggar
http://blogs.msdn.com/b/cjohnson/archive/2010/10/28/announcing-sharepoint-easy-setup-for-developers.aspx

http://blogs.msdn.com/b/pstubbs/archive/2010/10/27/sharepoint-2010-easy-setup-script.aspx

Tim Scharinger
2011-05-04
Вула Чăвашла

VulaCV - Чăвашла вулаттаракан сайт

Discovering SharePoint

And going crazy doing it

Bram de Jager - Coder, Speaker, Author

Office 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Paul J. Swider - RealActivity

RealActivity is a specialized Microsoft healthcare services and solution advisory firm.

Cameron Dwyer | Office 365, SharePoint, Outlook, OnePlace Solutions

Office 365, SharePoint, OnePlace Solutions & Life's Other Little Wonders

paul.tavares

Me and My doings!

Share SharePoint Points !

By Mohit Vashishtha

Jimmy Janlén "Den Scrummande Konsulten"

Erfarenheter, synpunkter och raljerande om Scrum från Jimmy Janlén

Aryan Nava

| Blockchain | Serverless Architecture | Microservices Architecture | DevOps | AWS Lambda | Teraform |

SPJoel

SharePoint for everyone

SharePointRyan

Ryan Dennis is a SharePoint Solution Architect with a passion for SharePoint and PowerShell

SharePoint 2020

The Vision for a Future of Clarity

Aharoni in Unicode

Treacle tarts for great justice

... And All That JS

JavaScript, Web Apps and SharePoint

blksthl

Mostly what I know about SharePoint - CommunicoCuspis