• Decrease Text SizeIncrease Text Size

Custom Form Processing

Posted Date: 5/2/2023
    Printer Friendly Version   Email A Friend   Add This   Increase Text Size   Decrease Text Size

In order to create custom Processing please follow instruction below.

  1. From Centralpoint\WebSites\cpweb_Development\Root\App_Code\DevV copy CustomInvokeMethod method into your cp:scripting file. Rename the Method to better describe what it will do in your system. Or you can copy example from a section code below.(Custom Form Processing Method)
  2. Rename the Method to better describe what it will do in your system.
  3. In the forms > Processing Tab check Custom = Yes (see #1 on the image below)
  4. In Method Name change the name to Method you just chose. (see #2 on the image below)
  5. Save the form.


public static void CustomFormProcessingMethod(object[] parameters)
{
    Centralpoint.WebSite.Page page = (Centralpoint.WebSite.Page)parameters[0];
    //FormGroup form = (FormGroup)parameters[1]; // not used in this example. Let you get all the parameters of the form. We will retrieve those using GetFormValue method. 
    string formProssesParameter = parameters[2].ToString(); // see #3 on the image below. you can pass any additional parameters or scripts from the console.
    HttpContext.Current.Trace.Warn("formProssesParameter", String.Format("{0}", formProssesParameter));

    string name = page.CpScripting.GetFormValue("Name"); // Id of the form Control. Form line 2
    HttpContext.Current.Trace.Warn("CustomFormProcessingMethod", String.Format("{0}", name));

     // Id of the form Control. The value of that control are 0 and 1. Form line 4
     bool workHereBefore = (page.CpScripting.GetFormValue("workHereBefore").Equals("1")) ? true : false; 
     if(workHereBefore)
     {
        //TODO: implement your logic for the case if the value is true(1).
     }
     else
     {
        //TODO: implement your logic for the case if the value is false(0).
     }

}


See Image:
CustomFormProcessing.png


Keywords: Form



Related Code Samples Records
  - Form State
Related Taxonomy

Comments:

Be the first to leave a comment.
Please Login to post comments.