Creating a Custom Control Project

The following steps provide guidance on how to create a SmartForms Custom Control project using Microsoft Visual Studio.

Create and configure the Visual Studio Project

  1. Create a Class Library Project in Microsoft Visual Studio
  2. Configure the Project Properties
    1. Edit the Assembly name and Default namespace if you need them to be different from the Project names (for example, companyname.projectname.customcontrolname). Note that these names are used in the Control Type Definition File
    2. Make sure that the Project is set to .Net Framework 4.6.1 for the Target framework in the Application Tab
    3. Use the Signing tab to sign the assembly with a strong-name key
    4. Optional: add Build Events commands to copy the project output dlls to the local design and runtime websites:
      Sample post-build event command line:
      xcopy "$(TargetDir)$(TargetName).*" "c:\Program Files\K2\K2 smartforms Designer\Bin\" /y /r
      xcopy "$(TargetDir)$(TargetName).*" "c:\Program Files\K2\K2 smartforms Runtime\Bin\" /y /r
  3. Save the Project
  4. Add the Project References
    1. Remove unneeded Microsoft C# references if required
    2. Add references to the .Net Framework components System.Web and System.Web.Services
    3. Browse to "%PROGRAMFILES%\K2\Bin\"
    4. Add references to SourceCode.Forms.Client.dll and SourceCode.HostClientAPI.dll
    5. Browse to "%PROGRAMFILES%\K2\K2 smartforms Runtime\bin"
    6. Add references to SourceCode.Forms.Controls.Web.SDK.dll and SourceCode.Forms.Controls.Web.Shared.dll
  5. Save the Project

Your Visual Studio project is now ready to start adding Custom Controls. To add a basic custom control to your project, go to the topic Create a Basic Custom Control