Skip to content

Instantly share code, notes, and snippets.

@Niels-V
Niels-V / FileCheck.cs
Last active October 29, 2015 12:36
PDF Check in a filestream
using System;
using System.IO;
using System.Text;
namespace Example
{
public class FileCheck
{
/// <summary>
/// Determines whether the specified file stream is a valid PDF.
@Niels-V
Niels-V / CustomUnobtrusiveValidator.cshtml
Last active September 3, 2015 21:39
Custom jQuery unobtrusive validator to check if either a input is filled or a checkbox is checked.
@{
ViewBag.Title = "Contact";
}
<h2>@ViewBag.Title.</h2>
<h3>@ViewBag.Message</h3>
@using (Html.BeginForm())
{
<input type="hidden" class="include-validation" name="test" data-val="true" data-val-requiredoptout="verplicht veld"
data-val-requiredoptout-optoutfieldselector="#testcheck" data-val-requiredoptout-requiredfieldselector="#test2" />
@Niels-V
Niels-V / AddDependentLookup.cs
Last active August 29, 2015 14:24
Provision additional lookup fields with CSOM
private void AddDependantLookup(List parentList, List targetList, Guid lookupFieldId, Field primaryLookupField, string displayName)
{
Field toField = parentList.Fields.GetById(lookupFieldId);
_clientContext.Load(toField);
_clientContext.Load(targetList);
_clientContext.ExecuteQuery();
Field dependantField = targetList.Fields.AddDependentLookup(displayName, primaryLookupField,
toField.StaticName);
FieldLookup dependantFieldLookup = _clientContext.CastTo<FieldLookup>(dependantField);
dependantFieldLookup.LookupField = toField.StaticName;
@Niels-V
Niels-V / UpdateWebPartTitles.cs
Created February 19, 2014 21:38
Change all webpart titles in a specific SP2010 pages library by CSOM.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.WebParts;
namespace UpdateWebPartTitles
{
@Niels-V
Niels-V / Execute-Tests.ps1
Last active December 31, 2015 23:39
Lightweight PowerShell monitoring solution. Write simple test in stand alone test cmdlets, and schedule the test runner with the Task Scheduler to receive a daily email with the test results.
Import-Module .\Tests\TestModule.psm1
Start-Tests -testContainer C:\Example\Tests