ActiveReports 18 .NET Edition
Report Authors / Design Reports / Design Section Reports / Scripts
In This Topic
    Scripts
    In This Topic

    In a section report, ActiveReports allows you to use VB.NET or C# script to port your custom logic to report layouts. This permits layouts saved to report XML (RPX) files to serve as standalone reports. By including scripting before you save the report layout as an RPX file, you can later load, run, and display the report directly to the viewer control without using the designer. In conjunction with report files, scripting allows you to update distributed reports without recompiling your project. 

    Script Editor

    To access the script editor, click the Script tab from the top menu in the Standalone Designer application or below the report design surface in Visual Studio Integrated Designer. The script tab contains two drop-downs (Object and Event).

    Add script to the events in the same way that you add code to events in the code view of the report. When you select an event, the script editor generates a method stub for the event.

    Using the ScriptLanguage property of the report, you can set the script language that you want to use.

    Select the scripting language to use

    You can also add scripts at run time using the Script property.

    Caution: Since the RPX file can be read with any text editor, use the AddCode or AddNamedItem method to add secure information such as a connection string.

    Tips for Using Script

    Difference in script and code-behind event handler

    Code-behind and the script tab require a different syntax for the event handler method definition. Use the Private modifier in code-behind and the Public modifier in the script editor.

    See the following examples of the ReportStart event handler definition in Visual Basic and C#:

    Script and code-behind examples in Visual Basic

    The ReportStart event handler definition in the script editor:

    Visual Basic.NET
    Copy Code
    Sub ActiveReport_ReportStart End Sub

    The ReportStart event handler definition in code-behind:

    Visual Basic.NET
    Copy Code
    Private Sub SectionReport1_ReportStart(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ReportStart End Sub

     

    Script and code-behind examples in C#

    C#
    Copy Code
    public void ActiveReport_ReportStart() { }

    The ReportStart event handler definition in code-behind:

    C#
    Copy Code
    private void SectionReport1_ReportStart(object sender, EventArgs e) { }
    See Also