Skip to content

Form Models

This Library lets you handle Form's Controller Actions, get the link of a specific Form, see which Controller is active or redirect user to a different application page.

Remote Pages Execution

Here, we'll show how to run Controller Actions that where created for a page Z, called by page A and how to get the link of another page.

Execute()

Description If you are in a page (e.g. SignInPage) and you want to redirect the user to another page (e.g. HomePage), first, you enter the name of the Form you will direct the user to (HomePage), then the word Controller, and then the actual Controller Action you want to be executed (Render).

Return Type : void

Static : Yes

Syntax

FormModels.HomePage.Controller.Render.Execute();

//When executing a Controller Action which has Parameters,
FormModels.ProductForm.Controller.EditProduct.Execute(Model.Product.Id);                
//In this case Model.Product.Id is the parameter of EditProduct(int id)

Warning

  • Only POST actions can be called from a Master Page
  • Only GET actions can be called from any other Page
  • (In general, a Master Page can have one and only one GET action)

Description

Returns a string with the URL link of a specific Form.

Return Type : string

Static : Yes

Syntax

string link = FormModels.HomePage.Controller.Render.GetLink();
//link = http://my-app.com/HomePage/Render          

Active Pages Execution

Here, we'll show how to run Controller Actions of the page you are currently at, how to get the URL link of the current page and how to check if a specific Controller is active.

Execute()

Description You can execute another Controller Action of the Form you are currently at.

Return Type : void

Static : Yes

Syntax

FormModels.ProductForm.Controller.AddProduct.Execute(); 
//Or Alternatively
Controller.AddProduct.Execute(); 

//When executing a Controller Action which has Parameters,
FormModels.ProductForm.Controller.EditProduct.Execute(Model.Product.Id);
//Or Alternatively
Controller.EditProduct.Execute(Model.Product.Id);
//In these cases, Model.Product.Id is the parameter of EditProduct(int id)

Warning

  • You can call any action (GET/POST) from your Current Controller

Description Returns a string with the URL link of the current Form.

Return Type : string

Static : Yes

Syntax

string link = FormModels.HomePage.Controller.Render.GetLink();
//link = http://my-app.com/HomePage/Render   

//Or Alternatively
string link = Controller.Render.GetLink();
//link = http://my-app.com/HomePage/Render   

IsActive()

Description Returns true or false depending whether the specified Controller Action is active or not, meaning that if the user is currently at the specified Form and Controller Action, the returned value will be true.

Return Type : bool

Static : Yes

Syntax

bool value = FormModels.HomePage.Controller.Render.IsActive();
// value = true, if the user is viewing HomePage's Render Controller Action

//Or Alternatively
bool value = Controller.Render.IsActive();
// value = false, if the user is not viewing HomePage's Render Controller Action

Exporting List Controls Data

Here, we'll show how to export data that would normally be displayed in List Controls, into files of various formats. This is very handy when you want to aggregate data from many different lists and deliver it to user in a single zip file.

{ListName}.Export({actionArgs...}, string, string)

Description Exports the data that would display int the specified List Control into a file and returns the actual full server path of this file.

Return Type : string

Static : Yes

Parameters

Name Data Type Description
actionArgs - The arguments required to execute the entry point Action of the specified Form
filename string The file name for the exported file, without extension
exportType string The type of the export. Allowed values: pdf, excel, word. Case insensitive

Warning

  • Authorization check is performed before exporting the list, based on the specified Action

Syntax

// Create a zip File
FileIOLib.ZipFile zip;

// Export to PDF
var file = FormModels.OperationsList.Controller.Retrieve.List.Export("Operations", "pdf");

// Add it to the zip File
zip.AddFile(file, "Operations Data");

// Export to Excel
file = FormModels.UsersList.Controller.Render.List.Export("Users", "excel");

// Add it to the zip File
zip.AddFile(file, "Users Data");

// Export a List of a Controller Action that requires parameters
file = FormModels.ManageUser.Controller.EditUser.PermissionsList.Export("Administrator", "AdminPermissions", "excel");
zip.AddFile(file, "Administrator Permissions");

zip.Save(FileIOLib.Path.Combine(FileIOLib.Path.GetTempPath(), "export.zip"));