Adding Custom Functions to Your Application
Calling your custom code functions is an integral part of customizing your generated application. Custom function can be used for variety of reasons such as displaying the results of a mathematical calculation and setting certain field values programmatically.
- Pooja Daga, Technical Support Engineer, Iron Speed, Inc.

May 31, 2006
Iron Speed Designer V3.2

Introduction
Calling your custom code functions is an integral part of customizing your generated application. Custom function can be used for variety of reasons such as displaying the results of a mathematical calculation and setting certain field values programmatically.
Procedure
Step1. To add custom functions to your application, create a .cs or .vb file for your code, such as CustomFunctionFile.cs or .vb. Your custom code file contains classes and methods and looks something like:

C#:

namespace myCustomNameSpace
{
    public class CustomFunction
    {
        public static bool myCustomFunction(int a)
        {
          if ((a < 10))
          {
            return true;
          }
          else
          {
            return false;
          }
        }
    }
}

Visual Basic.NET:

Namespace mynameSpace
Public Class CustomFunction
    Public Shared Function myCustomFunction(ByVal a As Integer) As Boolean
      If (a < 10) Then
          Return True
      Else
          Return False
      End If
    End Function
End Class
End Namespace

Step 2: Include your custom code file in your Iron Speed Designer-generated application.

For .NET Framework 1.1, place the .cs or .vb file in any folder that is part of your application.

For .NET Framework 2.0, the file must be placed in the App_Code folder located in:

...\<Application Folder>\App_Code

Using Visual Studio .NET to compile your application

If you are using Visual Studio .NET to compile your application, identify the custom code file to Visual Studio .NET. In Visual Studio .NET, select Add, Add Existing Item.

Using CSC or VBC to compile your application

If you are using the CSC or VBC compiler, your custom code file will be automatically compiled as part of your application.

Step 3: Add a declaration at the top of any Safe class file in your application where your custom code function is called.

C#:

using myCustomNameSpace;

Note: myCustomNameSpace is the namespace declared in CustomFunctionFile.cs.

Visual Basic .NET, .NET Framework 1.1:

Imports MyAppvb1.mynameSpace.CustomFunction

Visual Basic .NET, .NET Framework 2.0:

Imports mynameSpace.CustomFunction

Note: MyAppvb1 is the application name, mynameSpace is the name space and CustomFunction is the class name in your custom code file, CustomFunctionFile.vb.

Step 4: Call your custom code function in your application page’s safe class.

C#:

myCustomNameSpace.CustomFunction.myCustomFunction(4);

Visual Basic .NET using the Visual Studio .NET compiler:

myCustomFunction(4)

Visual Basic .NET, .NET Framework 1.1 using the VBC compiler:

mynameSpace.CustomFunction.myCustomFunction(4)

myCustomNameSpace is the name space, CustomFunction is the name of the class and
myCustomFunction is the method defined in the CustomFunctionFile.cs.

About the Author
Pooja Daga
Technical Support Engineer, Iron Speed, Inc.

Pooja has experience developing Web applications using .NET technology. She started her career with PCS, a leading software services company headquartered in India and has been with Iron Speed since 2005.

Pooja holds an M.S. degree in Computer Application and a B.S. degree in Electrical engineering from Maharaja Sayajirao University in India.



  Privacy Statement