Can ReportViewer render a hyperlink with a relative path?

穿精又带淫゛_ 提交于 2019-12-24 20:45:57

问题


I have created a local report on a datasource that has a field named "RelativePath". When my WinForms app renders the report, it exports files to the location specified in the RelativePath field. In the report builder, I set Navigation|Hyperlink action|Jump to URL to "=Fields!RelativePath.Value" and set the report's EnableHyperlink property to true. Whenever my app renders the report, however, the hyperlink is not active. If I hardcode the Jump to URL to an absolute path, however, it works just fine. Does the ReportViewer not render a hyperlink with a relative path?


回答1:


I have been struggling with the same problem after which i came to the conclusion that the reportviewer does not support hyperlinks with the relative path. To solve this problem is by adding a custom code that retrieves the relative path then concantenate with the field values that you may wish to be part of the URL - atleast that works for me.

Shaddie




回答2:


I encountered the same issue. To work around this, I created a Report Parameter called "AbsolutePath".

Go to the design view of the .rdlc file. On the "Report Data" tab, you'll see a "Parameters" node. Right click it to:

  1. Add Parameter...
  2. On the General Tab, enter "AbsolutePath" in the Name property.
  3. Click on "Default Values"
  4. Select the "Specify values" radio button.
  5. Add new value "AbsolutePath".

In your TextBox's Action Expression, add something like this ="javascript:void(window.open('" + Parameters!AbsolutePath.Value + "/yourpage.aspx?id=" + Fields!Id.Value + "', '_blank'))"

You can see that the new "AbsolutPath" parameter is available to add to your expression.

Now, you'll need to pass the value into the report's paramter, like so.

    string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
    var param = new ReportParameter("AbsolutePath", baseUrl);
    this.ReportViewer.LocalReport.SetParameters(param);



回答3:


Just use global variable Globals!ReportServerUrl in the expression

= Globals!ReportServerUrl + "yourpath"


来源:https://stackoverflow.com/questions/401664/can-reportviewer-render-a-hyperlink-with-a-relative-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!