Skip to main content
A newer version of this page is available. .

XRControl.NavigateUrl Property

Bindable. Specifies the URL to navigate to when the control is clicked.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

[SRCategory(ReportStringId.CatNavigation)]
[DefaultValue("")]
public virtual string NavigateUrl { get; set; }

Property Value

Type Default Description
String String.Empty

A String value containing the URL.

Remarks

Note

The NavigateUrl property is bindable, which means that it can be bound to a data field in a report’s data source. To learn more, see the Binding Report Controls to Data section.

Use the NavigateUrl property to specify an URL which the client web browser navigates to whenever the XRControl is clicked. If the NavigateUrl property is assigned, the XRControl serves as a link. If the property is set to an empty string (String.Empty) no navigation is performed when the control is clicked. The Web browser displays a Web page in the window or frame as specified by the XRControl.Target property.

To make the hyperlink work properly, start the URL with the “http://“ or “https://“ prefix.

Important

Users of the End-User Report Designer for the Web can add a “javascript:” prefix to the NavigateUrl property value, which allows the link to execute JavaScript code on the client, making other users vulnerable to cross-site scripting (XSS) attacks.

By default, JavaScript code execution is prohibited by the ASPxDocumentViewer and ASPxWebDocumentViewer controls. If your application relies on scripts in URLs, you can explicitly enable them using the following properties.

Not all descendants of the XRControl class use the NavigateUrl property. For example, the Band class descendants ignore this setting.

Example

This example demonstrates how to create a hyperlink in a report. Note that such label behaves as a hyperlink both in a report’s Print Preview and HTML, PDF, RTF, XLS and XLSX formats.

To add a hyperlink, to the Report Detail Band, handle the Report’s XRControl.BeforePrint event in the following way.

using DevExpress.XtraReports.UI;
// ...

private void XtraReport1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
    // Create a new hyperlink and add it to the report's Detail Band.
    Bands.GetBandByType(typeof(DetailBand)).Controls.Add(CreateHyperlink());
}

The code below creates a hyperlink using the XRLabel object, and specifies its XRControl.NavigateUrl, XRControl.Target and other properties.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

public XRLabel CreateHyperlink(){
    // Create a label for a hyperlink.
    XRLabel hyperlinkLabel = new XRLabel();

    // Set its main properties.
    hyperlinkLabel.Text = "DevExpress Inc.";
    hyperlinkLabel.Width = 200;
    hyperlinkLabel.ForeColor = Color.Blue;
    hyperlinkLabel.Font = new Font("Tahoma", 12, FontStyle.Underline);

    // Set its URL and target.
    hyperlinkLabel.NavigateUrl = "http://www.devexpress.com";
    hyperlinkLabel.Target = "_blank";

    return hyperlinkLabel;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the NavigateUrl property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also