Can ReportViewer display a hyperlink with a relative path?
I have created a local report on a data source that has a field named "RelativePath". When the WinForms application displays the report, it exports the files to the location specified in the RelativePath field. In Report Builder, I have set the Navigation | Hyperlink | Jump to URL to "= Fields! RelativePath.Value" and set the report's EnableHyperlink property to true. However, when my application displays the report, the hyperlink is not active. However, if I hard-code the jump url to an absolute path, it works fine. Does ReportViewer display a hyperlink with a relative path?
source to share
I was struggling with the same problem, after which I came to the conclusion that Reportviewer does not support relative path hyperlinks. To fix this, add custom code that extracts the relative path, then combine with field values ββthat can be part of the url, at least for me.
Shaddie
I faced the same problem. To work around this, I created an "AbsolutePath" report parameter.
Go to your project .rdlc file. Under the "Report Data" tab, you will see the "Parameters" node. Right click on it:
- Add parameter ...
- On the General tab, enter AbsolutePath for the Name property.
- Click on "Defaults"
- Select the "Specify Values" radio button.
- Add new value "AbsolutePath".
In your ActionBox Action expression add something like this = "javascript: void (window.open ('" + Parameters! AbsolutePath.Value + "/yourpage.aspx?id=" + Fields! Id.Value + "', '_blank ')) "
You can see that a new "AbsolutPath" parameter is available to add to your expression.
Now you need to pass the value to the report parameter, for example.
string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
var param = new ReportParameter("AbsolutePath", baseUrl);
this.ReportViewer.LocalReport.SetParameters(param);
source to share