# Bookmarks

Learn how to set up basic bookmarks, leveled or nested bookmarks in section reports. This topic also explains how to nest grandchild bookmarks and use them in grouping, combine parent report and subreport bookmarks, and add bookmarks to a predefined page.

## Content

In a Section report, bookmark links take you to a location where the bookmark is set on your report. Bookmarks and nested bookmarks appear in the document map for fields, groups, and subreports. You can also add special bookmarks at run-time.

Bookmarks are supported when you preview a report in the Viewer, or export a report in [HTML](/activereportsnet/docs/v19.2/developers/export-reports/exporting-page-rdl-section-reports/html-export) and [PDF](/activereportsnet/docs/v19.2/developers/export-reports/exporting-page-rdl-section-reports/pdf-export) formats. See [Document map](/activereportsnet/docs/v19.2/report-readers/desktop-viewers/windows-forms-viewer#document-map-pane) for more information. The following sections show setting up bookmarks in some scenarios in XML-based Section reports. Note that the same scripts are equally applicable to Code-based Section reports with cautious use of casing.

## Set up basic bookmarks

1. From the toolbox, drag and drop a [TextBox](/activereportsnet/docs/v19.2/report-authors/report-controls/report-controls-section-report/textbox-section) control onto the **Detail** section.
2. Double-click the **Detail** section of the report. This creates an event-handling method for the report's Detail\_Format event.
3. Add the following script to set up bookmarks.

    ```vbnet
    Detail.AddBookmark(TextBox1.text)
    ```

    ```csharp
    Detail.AddBookmark(TextBox1.Text);
    ```

## Set up leveled or nested bookmarks

> ![Leveled or Nested Bookmarks in a Section Report](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/design-reports/bookmark-nested.png)

Bookmarks can be nested to reflect a hierarchical structure; this is sometimes called a parent-child relationship.

1. Create a new section report and bind it to JSON data using the following connection string and JSON path. See [JSON Provider](/activereportsnet/docs/v19.2/report-authors/data-binding/data-binding-in-section-reports/connect-to-a-datasource-section/json-provider-section) for more information.

    ```plaintext
    method=POST;headers={"Content-Type":"application/json"};body={ "query": "{employees{country, city, superior{firstName,lastName,title}}}" };jsondoc=https://demodata.mescius.io/northwind/graphql
    ```

    ```javascript
    $.data.employees[*]
    ```
2. From the Report Explorer, drag and drop country and city onto the **Detail** section.
3. Double-click the **Detail** section of the report. This creates an event-handling method for the report's Detail\_Format event.
4. Add the following script to set up leveled or nested bookmarks.

    ```vbnet
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text)
    ```

    ```csharp
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text);
    ```

## Nest grandchild bookmarks and use bookmarks in grouping

> ![Nested Grandchild Bookmarks in Grouping](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/design-reports/bookmark-nestedgrandchild.png)

1. Follow [Step 1](/activereportsnet/docs/v19.2/report-authors/design-reports/design-section-reports/interactivity-section/bookmarks-section#bind) of the previous section to create a new section report and bind the data.
2. From the Report Explorer, drag and drop country, city, and superior.title fields onto the **Detail** section.
3. Double-click in the **Detail** section of the report. This creates an event-handling method for the report's Detail\_Format event.
4. Add the following script to set up a bookmark for each superior.title and nest superior.title bookmarks within each city, and city bookmarks in each country.

    ```vbnet
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text)
    ```

    ```csharp
    Detail.AddBookmark(txtcountry1.Text + "\\" + txtcity1.Text + "\\" + txtsuperior_title1.Text);
    ```
5. Add a **Group Header** section to the layout and set its **DataField** property to country.
6. Double-click in the Group Header section of the report. This creates an event-handling method for the report's Group Header Format event.
7. Add the following script to set up a bookmark for each instance of the country group.

    ```vbnet
    GroupHeader1.AddBookmark(txtcountry1.Text)
    ```

    ```csharp
    GroupHeader1.AddBookmark(txtcountry1.Text);
    ```

## Add bookmarks to a predefined page

> ![Bookmarks to a Predefined Page](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/design-reports/bookmark-predefinedpages.png)

To create and add special bookmarks to the bookmarks collection at run time, add the bookmarks to the report document's page collection.

> type=warning
> **Caution**: Remember that the page collection does not exist until the report runs, so use this code in the ReportEnd event or in form code after the report has run.

1. Go to the **Script** tab of the report designer.
2. Select **ActiveReport** as **Object** and **ReportEnd** as **Event**. This creates an event-handling method for the ReportEnd event.
3. Add the following script to create bookmark for the pages.

    ```vbnet
    rpt.Document.Pages(0).AddBookmark("Page1", 1)
    rpt.Document.Pages(1).AddBookmark("Page2", 2)
    rpt.Document.Pages(2).AddBookmark("Page3", 3)
    ```

    ```csharp
    rpt.Document.Pages[0].AddBookmark("Page1", 1);
    rpt.Document.Pages[1].AddBookmark("Page2", 2);
    rpt.Document.Pages[2].AddBookmark("Page3", 3);
    ```

## Combine parent report and subreport bookmarks

> ![Combined Parent Report and Subreport Bookmarks](https://cdn.mescius.io/document-site-files/images/b298aea2-8cb8-4a0f-be88-4f54aa263ebd/images/design-reports/bookmark-combined-main-subreport.png)

1. Create a new section report and bind the data as [Step 1](/activereportsnet/docs/v19.2/report-authors/design-reports/design-section-reports/interactivity-section/bookmarks-section#bind) of another section. This will be the parent report.
2. From the Report Explorer, drag and drop the country field onto the detail section of the parent report.
3. Double-click the Detail section to create an event-handling method for the report's Detail Format event.
4. Add the following script to create a bookmark for each instance of the country field in the parent report.

    ```vbnet
    Private _subRpt As GrapeCity.ActiveReports.SectionReport
    Public Sub Detail_Format()
        SubReport1.Report = _subRpt
        Detail.AddBookmark(txtcountry1.Text)
    End Sub
    Public Sub ActiveReport_ReportStart()
        _subRpt = New GrapeCity.ActiveReports.SectionReport()
        _subRpt.LoadLayout(System.IO.Path.GetFullPath("..\..\..\SubReport1.rpx"))
    End Sub
    ```

    ```csharp
    GrapeCity.ActiveReports.SectionReport _subRpt;
    public void Detail_Format()
    {
        SubReport1.Report = _subRpt;
        Detail.AddBookmark(txtcountry1.Text);
    }
    public void ActiveReport_ReportStart()
    {
        _subRpt = new GrapeCity.ActiveReports.SectionReport();
        _subRpt.LoadLayout(System.IO.Path.GetFullPath(@"..\..\..\SubReport1.rpx"));
    }
    ```
5. Drag-drop [Subreport](/activereportsnet/docs/v19.2/report-authors/report-controls/report-controls-section-report/subreport-section) control onto the design area. By default, the **ReportName** property is set to SubReport1.
6. Create a new Section report with the name 'SubReport1', which will be a subreport to the parent report.
7. Bind a newly created report to data as described in [Step 1](/activereportsnet/docs/v19.2/report-authors/design-reports/design-section-reports/interactivity-section/bookmarks-section#bind) of the section above.
8. From the Report Explorer, drag and drop the city field onto the detail section of the subreport.
9. Double-click in the Detail section to create an event-handling method for the subreport's Detail Format event.
10. Add the following script to create a bookmark for each instance of the city field in the subreport.

```auto
```vbnet
Detail.AddBookmark(CType(rpt.ParentReport.Sections("Detail").Controls("txtcountry1"), TextBox).Text + "\" + txtcity1.Text)
```

```csharp
Detail.AddBookmark(((TextBox) (rpt.ParentReport.Sections["Detail"].Controls["txtcountry1"])).Text + "\\" + txtcity1.Text);
```

```auto

11. Preview the main report and navigate to Document Map. You will see bookmarks for city from the subreport nested into bookmarks for country from the main report.
```