XRControl.NavigateUrl Property

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

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v20.2.dll

Declaration

[SRCategory(ReportStringId.CatNavigation)]
[DefaultValue("")]
public virtual string NavigateUrl { get; set; }
<SRCategory(ReportStringId.CatNavigation)>
<DefaultValue("")>
Public Overridable Property NavigateUrl As String

Property Value

Type Default Description
String

String.Empty

A string that corresponds to a URL.

Remarks

Use the NavigateUrl property to specify the URL of a web page to which a web browser navigates when you click a control. Start the URL of a web page with a "http://" or "https://" prefix. To specify a window or frame in which a browser opens a new page, use the control's Target property.

You can also specify an absolute or relative path to a file in the NavigateUrl property.

NOTE

Not all XRControl class descendants implement the NavigateUrl property. For example, this property is hidden in the Band class descendants.

Specify Execution Policy for User-Invoked Processes

When you click a control with a specified NavigateUrl property, a new process is started. For example, if the property points to a web page, a browser is opened. In case of a .txt file, the default text editor is executed.

You can specify an execution policy for processes users initiate to avoid possible security issues. To do that, call one of the DevExpress.Data.Utils.ProcessStartPolicy class methods at application startup:

  • SuppressAll() - suppresses all processes. You can click controls with a specified NavigateUrl property but no processes are executed.
  • ThrowAlways() - throws an exception when a process starts.
  • RequireConfirmation() - shows a confirmation dialog that prompts you to confirm or cancel a process.

If you do not call these methods, processes are not affected when you click a control.

The following code suppresses all processes users initiate:

static void Main() {  
    DevExpress.Data.Utils.ProcessStartPolicy.SuppressAll();  
    //...  
} 

Execute JavaScript Code

You can add a "javascript:" prefix to the NavigateUrl property in the Web End-User Report Designer and execute JavaScript code on the client. Since this makes other users vulnerable to cross-site scripting (XSS) attacks, JavaScript code execution is disabled in the ASPxWebDocumentViewer control. If your application uses JavaScript code in URLs, use the following properties to enable JavaScript code execution:

Bind to Data

You can bind the NavigateUrl property to a data field in a report's data source. For more information, refer to the following article: Bind Report Controls to Data.

Examples

This example demonstrates how to use the XRLabel control to create a hyperlink.

The code below creates the XRLabel control, sets up its appearance, and specifies its NavigateUrl and Target 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;
}

To add the hyperlink to the report's Detail band, handle the report's BeforePrint event:

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 label behaves like a hyperlink in a report's Print Preview and in a document exported to HTML, PDF, RTF, XLS, and XLSX formats.

See Also