Hyperlinks and Bookmarks

  • 4 min to read

Overview

A document can contain hyperlinks pointing to external locations or associated with bookmarks in the same document.

Bookmark

A Bookmark exposes a document range with a name. The range can have zero length. The name should start with a letter and must be unique in the collection of bookmarks in the current document.

To create a new bookmark, invoke the end-user Insert Bookmark dialog using the Bookmark ribbon button located in the ribbon's Insert tab in the Links group. The Bookmark form is illustrated in the following picture.

EditBookmarkForm

Note

The bookmarks whose names begin with the underscore symbol ("_") are not displayed within the Bookmarks dialog.

You can visualize a bookmark in a document, and specify its color using the ASPxRichEditSettings.Bookmarks property (in the Settings.Bookmarks notation), as illustrated below.

BookmarkColor

Bookmarks in the document can be referenced by a Hyperlink. While inserting, a hyperlink can be customized to point to a bookmark specified by its name within the document.

Client API

Programmatically, a bookmark is implemented as the Bookmark client object. A list of bookmark objects in the sub-document can be accessed through the bookmarksInfo client property (SubDocument.bookmarksInfo) in the following notation:

clientRichEditName.document.activeSubDocument.bookmarksInfo

You also can use the SubDocument.findBookmarks method to get portion of bookmarks that are filtered by their location (using overloads with position, interval, and intervals parameters) or name (using overloads with name or regExp parameters).

A bookmark can be defined using the following characteristics.

  • Start position (Bookmark.start)

    A position in a sub-document text buffer where a bookmark starts.

  • Length (Bookmark.length)

    The number of characters in a bookmark within the text buffer.

  • Name (Bookmark.name)

    The bookmark name.

The following client commands are available for manipulating hyperlinks in a document. Call the commands in the notation given below:

clientRichEditName.commands.commandName.execute(parameter_if_any)

Command Name Link Description
deleteBookmark RichEditCommands.deleteBookmark Gets a command to delete a specific bookmark.
goToBookmark RichEditCommands.goToBookmark Gets a command to navigate to the specified bookmark.
insertBookmark RichEditCommands.insertBookmark Gets a command to insert a new bookmark that references the current selection.
openInsertBookmarkDialog RichEditCommands.openInsertBookmarkDialog Gets a command to invoke the Bookmark dialog window.

The Hyperlink marks the document range as the hot spot in the document. It can be activated with a mouse click to navigate the specified location (an external web resource or a local document bookmark). An external hyperlink is opened in a new browser tab. The hyperlink has a tooltip, and can be marked as visited.

To create a new hyperlink, invoke the end-user Insert Hyperlink dialog using the Hyperlink ribbon button located in the ribbon's Insert tab in the Links group. The Hyperlink form is illustrated in the picture below.

EditHyperlinkForm

In a document, hyperlinks are represented by a document field of the HYPERLINK type. See the Document Fields and Field Codes topics to learn more.

Client API

Programmatically, hyperlink settings can be defined using the properties exposed by the HyperlinkSettings client object. When inserting a new hyperlink, this object (its settings) can be passed as a parameter to the InsertHyperlinkCommand.execute method of the RichEditCommands.insertHyperlink command in the following notation.

clientRichEditName.commands.insertHyperlink.execute({text: "Go to URL", url: "example.com", tooltip: "Click to redirect"})

When clicked (or activated by other means), a hyperlink fires the ASPxClientRichEdit.HyperlinkClick event.

The following client commands are available for manipulating hyperlinks in a document. Call the commands in the notation given below:

clientRichEditName.commands.commandName.execute(parameter_if_any)

Command Name Link Description
deleteHyperlink RichEditCommands.deleteHyperlink Gets a command to delete the selected hyperlink.
deleteHyperlinks RichEditCommands.deleteHyperlinks Gets a command to delete all hyperlinks in the selected range.
insertHyperlink RichEditCommands.insertHyperlink Gets a command to insert and update a hyperlink field in place of a selected range.
openHyperlink RichEditCommands.openHyperlink Gets a command to go to a bookmark or URI contained within the selected hyperlink.
openInsertHyperlinkDialog RichEditCommands.openInsertHyperlinkDialog Gets a command to invoke the Hyperlink dialog window.
See Also