CHUVASH.eu

CHunky Universe of Vigourous Astonishing SHarepoint :)

Tag Archives: tips

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.

javascript: developing for performance

Many words have been said about the importance of performance when working with javascript files. Here I want to summarize what developers can do to increase the performance related to javascript. I found many tips on blogs. Here comes my aggregated list of actions one can do to speed up sharepoint (and not only) sites with focus on javascript:

1. Load only sharepoint stuff you need

Use prefetch option to only load sharepoint javascript files that needed. To see the difference, just add ?prefetch=0 to your sharepoint url in the browser.

The downside of this lazy loading is that you wrap all sharepoint related javascript into ExecuteOrDelayUntilScriptLoaded otherwise you maybe invoke some of javascript objects and functions that are not loaded. So the prize of this huge performance improvement is a high awareness by a developer when and which scripts are loaded and run.

2. Load only custom stuff you need

The same lazy loading principle should be used for your scripts as well, unless your javascript code is little. If your projects have much of functionality on client side, than you can increase loading performance enormously. This post is not about details, but when you want to know more about “On Demand javascript“, take a look about SP.SOD, head.js, require.js.

3. Minify all your scripts

Minify or crunch your javascript files. There are many tools available for doing that: google closure compiler, jscrunch… But the best javascript minifying tool for SharePoint development I found is Mavention SharePoint Assets Minifier which is developed by Waldek Mastykarz and highly integrated with Visual Studio and SharePoint debug/release modes.

4. Minimize your scripts

Not only how much javascript is loading matter, but how many files as well. Like sprites in CSS, you can combine your scripts into one that you load. Just organize your scripts as they were classes (one class – one file), then use T4 to generate a composite javascript file.

5. Check your javascript for memory leaks

Thinking about memory leaks is important, and not only in SharePoint Server Side. It is important to avoid memory leaks in javascript as well. Especially when your audience uses older browsers. See this amazing post about javascript memory leaks on Ying’s blog.

This is all so far. Have I missed something, please comment.

Out-Gridview in PowerShell

Did you know that we can pipe the output from PowerShell into a graphical GridView? I have used PowerShell for one year and only now I discovered this nice feature. You can add filter criteria, you can filter by typing in a textbox:

Other useful output cmdlets
  • out-file
  • out-clip
  • out-null

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

 

Powershell scripts for AD

A tip for all who want to administer AD with powershell: Idera Powershell scripts. Just sign up and get the free scripts for AD, SQL, Exchange and Sharepoint.

I personally prefer to user modules, so I change the file extension from ps1 to psm1 and then I can use import functions as modules. Here is a simple example for creating for domain users:

import-module .\New-IADUser1.psm1
function Add-User($name) {
    New-IADUser -Name $name 
         -sAMAccountname $name 
         -ParentContainer 'CN=Users, DC=contoso, DC=com' 
         -Password 'SvenskaAkademien1786' 
         -EnableAccount -PasswordNeverExpires
}
Add-User "user01"
Add-User "user02"
Add-User "user03"
Add-User "user04"
update 2012-03-15: nice script from Ryan

Ryan Dennis has created a very handy script for creating random users.

In PowerShell v3.0 there is a cmdlet for creating users: New-ADUser. So the function above can be rewritten like that:

Import-Module ActiveDirectory -ErrorAction SilentlyContinue
function Add-User($name) {
    $password = ConvertTo-SecureString 'SvenskaAkademien1786' -AsPlainText -Force
    New-ADUser -Name $name 
         -sAMAccountname $name 
         -Path 'CN=Users, DC=contoso, DC=com' 
         -AccountPassword $password
         -Enabled $true
         -PasswordNeverExpires $true
}
Add-User "user01"
Add-User "user02"
Add-User "user03"
Add-User "user04"

Check if an html element is hidden using jQuery

Well, sometimes we need to calculate width and so on. In my next post I will write about how to fix auto-resize on fixed sized master pages. But now: a very nice stuff: how to check if an element is hidden or not:

$("#s4-leftpanel").is(":visible")

It is a pure poetry. It reminds me of the beauty of symbols in Ruby.

Good pattern for javascript files

SP.js exists in two variants in debug mode and in modified. When you develop it is better to use debug mode. When it goes to production it is better to use minified files. The same you can do with your files. Wictor Wilen explains how to do minify your custom javascript files. I think it is a good pattern to create javascript files and call them something-something.debug.js. Then when you are done, run the custom tools to minify them.

Todolist in VS

A really nice feature is a task list. Just write //TODO something something in your code and it appears in the task list which can be shown through View – Task List in Visual Studio.

Increase performance while retrieving data with LINQ to SP

If you are just intrested in getting data, not writing to the source like SubmitChange, you can disable ObjectTracking and increase the performance.

context.ObjectTrackingEnabled = false;

I found this tip on page 248 in the book “Sharepoint 2010 as a development platform

Windows 8 preview

windows 8I have tested the Windows 8 developer preview. VMWare player 3 didn’t manage it, so I installed VirtualBox and it ran very well. One thing I did was to enable full screen on VirtualBox.

Here is the list of features you get if you install the developer preview:

  • Windows SDK for Metro style apps
  • Microsoft Visual Studio 11 Express for Windows Developer Preview
  • Microsoft Expression Blend 5 Developer Preview
  • 28 Metro style apps including the BUILD Conference app
Вула Чăвашла

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

Discovering SharePoint

And going crazy doing it

Bram de Jager - Architect, Speaker, Author

Microsoft 365, SharePoint and Azure

SharePoint Dragons

Nikander & Margriet on SharePoint

Cameron Dwyer

Office 365, SharePoint, Azure, 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

DevOps, Cloud and Blockchain Consultant

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

SharePointDiver

SharePoint på ren svenska