In Iron Speed, there was a special code file that contained built-in functions and formulas that could be used in your app. To add a custom function of your own, you merely added it to that file. Of course, ASPR.net comes with built-in functions as well, but the code is not designed to be extensible.
It's really handy to be able to call a custom function when you have some advanced processing you want to do on a field value, for instance. To accomplish this is ASPR.net, I created my own custom class file. It was really easy to do and now I do this for every app I develop. Here's how I did it.
It helps to have Visual Studio, but it's not necessary.Create a new class file in /source/include. Make sure to add all the includes you will need and declare the namespace. Here is my skeleton file I use as a starting point:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Reflection;
using runnerDotNet;
namespace runnerDotNet
{
public class PkFunctions
{
public static string TestFunction()
{
return "Hello world!";
}
}
}
Name your class whatever you like -- I call mine PKFunctions. So to call my test function, I merely insert something like:
value = PkFunctions.TestFunction();
Easy peasy!