Add the Static Method in a Class
Add a namespace with a class that will contain your static method.
Note: You will have to manually register the namespace with the SharePoint 2013 Management Shell, see Add the Custom Inline Function using PowerShell
In this section, add the following class to your project:
Code
You can download the code used in this example from the following location:
2013_ONPREM_NF_CustomControl.zip
Note: You need to configure the code for the example before you can build and run it. See Prepare the Visual Studio project for instructions on how to configure the code for the example.
Add Custom.cs
Create the class named Custom.cs. You can refer to the code comments in the sample code for more details.
To add the MyCustomSliderControl Class
- Right-click the name of your class in the solution file in the Solution Explorer in Visual Studio, click Add, and select Class.
- Name the class, MyCustomSliderControl.cs, and add the sample code.
namespace Custom.InlineFunctions.Custom
{
///
/// Custom class. Is used to expose static methods which can be used for insert references.
///
public class Custom
{
///
/// Converts a string into Pig Latin.
///
/// The string to translate to Pig Latin.
/// Returns the string in Pig Latin.
public static string Piglatin(string piggy)
{
char firstchar = piggy[0];
string isVowel = "aeiouAEIOU";
if (isVowel.IndexOf(firstchar) >= 0)
{
string output = piggy + "yay";
return output;
}
else
{
string stem = piggy.Substring(1);
string output = stem + firstchar + "ay";
return output;
}
}
}
}
Add a Custom Inline Function with SharePoint 2013 Management Shell