博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

报表中新建窗口打开超链接

Posted on 2011-04-12 21:09  光照峋山  阅读(262)  评论(0编辑  收藏  举报

Navigating to other reports or any web URL
- Drag a datafield on the report
- Click on the Textbox
- Find the Action property of Textbox the property window
- Select Go to URL option
- Type any valid URL (i.e. http://binaryworld.net/Main/CodeDetail.aspx?CodeId=3668), valid URL must start with protocol like http: ,ftp:, mailto: ...
Opening Link in a new window
Well this is very common requirement but unfortunately there is no direct option available in Reporting Services Designer. You can do that using the following technique
Use the following expression in the "Go to URL"

="javascript:void(window.open('http://binaryworld.net/Main/CodeDetail.aspx?CodeId=3668','_blank'))"
How to overcome expression length limitation (Dynamicly generate hyperlink)
Another limitation of "Go to URL" field is you are limited to Maximum expression characters. You can solve this problem by using "Dummy parameters". You can create parameters for report without any prompt string and then specify default value which will act as a constant for your report.
For example if I have a really long URL which is not allowed in the "Go to URL" expression then I can create a new report parameter called CW_URL. Set your long URL as default value for this parameter. Now remove any prompt string for this parameter so it wont appear when you run your report.
default value for cw_url => http://binaryworld.net/Main/CodeDetail.aspx?CodeId=
Now you can type the following expression in "Go to URL" to get dynamic URL based on Database field called CodeID and static URL from cw_url hidden parameter.  
="javascript:void(window.open('" & Parameters!cw_url.Value & Fields!CodeId.value & "','_blank'))"