Button Actions

Go to:

Property Sheet, Button control, Button actions property

The action specifies the action taken, or transaction performed, by the button when it is clicked.

The action specifies the transaction operation to perform when the button is clicked.

 

Action

Description

Add row to

Add a new record to the database.  Processing does not wait until a final “Submit” or “OK” button is clicked.

Apply search and filter to

Applies the current filtering criteria, including a search, to the control.  This operation is normally used for the “Go” button in a search panel or a dropdown filter.  The search term is entered into a separate text box field.

Custom

An application-defined custom command is executed when the button is clicked.  When clicked, the button will emit an event by this name, which can be intercepted in a code extension to your application and processed.  See Calling a custom function when a button is clicked for details.

Delete current record

In Show Record panels, the selected record is deleted from the database immediately.  Processing does not wait until a final “Submit” or “OK” button is clicked.

In Edit Record panels, the selected record is removed from the control so that it is no longer displayed.  The record is deleted from the database and the transaction committed only after a final “Save”, “Submit” or “OK” button is clicked.

Note:  The ‘Delete current record’ command will only delete the designated record.  It will not delete related records that refer to the deleted record.  See Deleting related records for details.

Delete selected row from

In Table Report panels, the selected record(s) are deleted from the database immediately.  Processing does not wait until a final “Submit” or “OK” button is clicked.

In Edit Table panels, the selected record(s) are removed from the control so that they are no longer displayed.  The record(s) are physically deleted from the database and the transaction committed only after a final “Save”, “Submit” or “OK” button is clicked.

Note:  The ‘Delete selected row from’ command will only delete the designated record(s).  It will not delete related records that refer to the deleted record(s).  See Deleting related records for details.

Export data to PDF from

Create a PDF report using data from the associated table.  A file selection dialog is displayed when the button is clicked, prompting the application user for a file name.

Export data to Excel from

Create a Microsoft Excel file containing data from the associated table.  A file selection dialog is displayed when the button is clicked, prompting the application user for a file name.

Export data to CSV from

Create an ASCII CSV file containing data from the associated table.  A file selection dialog is displayed when the button is clicked, prompting the application user for a file name.

Export data to Word from

Create a Microsoft Word report using data from the associated table.  A file selection dialog is displayed when the button is clicked, prompting the application user for a file name.

Import data from

Imports data into the selected table from ASCII CSV, Microsoft Excel and Microsoft Access files.  A wizard is displayed when the button is clicked, prompting the application user for a file name and other details.

You must specify a ‘Go to specific URL’ action (via the Button Action Wizard) to launch the Import Wizard and designate the database table to receive the imported data.  The URL has the format:

../Shared/SelectFileToImport.aspx?TableName=Categories

SelectFileToImport.aspx is the Import Wizard.  ‘Categories’ is an example of the database table receiving the imported data.

Pagination

Perform the selected table pagination operation.

Redirect

A new page, specified by the URL, is displayed.

Refresh page

Restores the current page (or form) to its last presented state.  For Add Record pages, the input fields are cleared of any data entered into them.  For Edit Record pages, the data fields are restored to their original values from the database.

Refresh page causes record controls and table controls to refresh their data from the database, even if the fresh data was from a concurrent modification by another user.  I.e., the most current data is always retrieved from the database.  It does not restore from the web browser’s local cache.

Note: Refreshing a page does not reset the filter settings or clear the search text box.  To clear the filters and search text box, simply redirect to the same page using the “Go to a specific URL” Button Action option.

Save data on page

Any input data and edited values on the page are updated (saved) into the database.  Any deleted records are removed from the database.

Save data on table or record

Any input data and edited values in the selected table or record are updated (saved) into the database.  Any deleted records are removed from the database.

Sign out

Sign out of the application.  The application user is logged out.

The Sign Out event is always consumed by the Page unless some form of code customization is employed relating to this event.

Action Options

Several of the Action options require additional options to be specified.

Option

Description

Enable client-side data validation

The data entered into the page is validated by the application.  All data in each data entry control on the page is validated.

Calling a custom function when a button is clicked

You can call custom code functions of your own when a button is clicked.  The invoked code is typically placed in the associated page’s customizable code-behind class (details about this are found elsewhere in the online help).  To “catch” the function call, override the OnApplicationEvent function.

Group

Property

Setting

[Application Generation]

Button actions

Custom

Appearance

Text

Export to PDF

Behavior

CausesValidation

No

Behavior

CommandName

DisplayAsPDF

For example, a button might call a custom function called “ExportToPDF” which is invoked when the button is clicked.  The OnApplicationEvent function implements an event handler that is called when the new “Export to PDF” button is clicked.  In this example, the DisplayReportAsPDF function connects to the data base, populates the report, and then displays it in the web browser.

Visual Basic .NET:

' This method handles the ApplicationEvent produced by the ExportToPDF button

Public Overrides Sub OnApplicationEvent(ByVal args As BaseClasses.ApplicationEventArgs)

 

     ' Handle the custom "DisplayAsPDF" command, but pass others off to the base class

     If args.EventType = BaseClasses.ApplicationEventArgs.EventTypes.Custom AndAlso _

          args.CustomEventName = "DisplayAsPDF" Then

          '' create the report object and produce the report

          Dim crReportDocument As New ProductsList()

          DisplayReportAsPDF(crReportDocument)

     Else

          ' not the custom "DisplayAsPDF" command, pass it on

          MyBase.OnApplicationEvent(args)

     End If

End Sub

Deleting related records

Sometimes when using the Delete Current Record action, you may see this error in your application:

"Cannot delete Main. A record you were attempting to modify is referenced by other records."

This happens because the Delete Current Record action does not recursively delete all the records in other tables that reference the deleted record.  For example, if an Order Detail record points to the main Order record, the Order record cannot be deleted unless the Order Details records that reference the particular Order record are deleted.

You can accomplish this in several ways.

Public Overrides Function DeleteRecord(ByVal recordIndex As Int32) As IRecord

To delete the OrderDetail records, write a simple “for” loop that goes through each record and calls the Delete method on each record.  Retrieve the record group using the GetList method.

Configuring Quick Add buttons

Quick Add buttons cannot be configured to send emails because a Click event is not created these buttons, i.e., the “Add…” button for ‘Redirect and Send Email Actions’ is disabled.

Related

Example: Configuring a Go Filter Button

Example: Keeping a Page On-Screen After Clicking Save

Example: Add a Logout Button to a Page

See Also

Button Actions and Properties

Button Actions

Button Actions - Redirect and Send Email Actions

Button Actions - Substitution Variables

Button Tag Properties