Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Relative URL in ReportViewer Action

Posted on 2014-09-08
14
Medium Priority
?
713 Views
Last Modified: 2014-09-11
Using a report viewer in an ASP web application and need to have one of the columns as a hyperlink to another page on the same site using a relative URL, but it is only working if I put in an absolute URL

For example:

This works ==> http://localhost:12345/myPage.aspx
This doesn't ==> ~/myPage.aspx

Obviously when I deploy the website the server name will change, so it can't be hard coded.

Is it possible to use relative url's?
0
Comment
Question by:BrianFord
  • 7
  • 6
14 Comments
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 40311429
I think relative path is not supported in the ReportViewer, So please write some custom code and create and  add URL from there.
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40311434
As far as I know relative paths for the Go To URL action are not supported, the first part (http) is crucial for SSRS to figure out what protocol to use for the navigation.

To avoid the issue of having to update each action when the server changes you can store the first part of the URL in a hidden report parameter and use an expression to build the URL for the action.  Then you only need to update that parameter on deployment.
Another option, if you really want to avoid the hardcoded server name, is to store it in a config table in a database and set up a small dataset to retrieve it.
0
 

Author Comment

by:BrianFord
ID: 40311803
Thanks,

I'm not really an expert on report expressions, do you know if it's possible to query the current server name as part of the expression? so that entering something like:

="HTTP://" & <current servername> & "/myPage.aspx"
or
=<current URL> & "/myPage.aspx"

would mean not having to change the data on deployment
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:ValentinoV
ID: 40311816
There is a global variable that returns the URL of the report server: Globals!ReportServerUrl

The string returned goes like this: http://yourserver/reportserver

Perhaps you can extract info out of that to be used in the URL expression?  However, this variable will only return useful info if your report server is running on the same box as your web server, if you need to refer to a website URL at least (as your example indicates).
0
 

Author Comment

by:BrianFord
ID: 40311889
My report is a 'local Report' and therefore not on a report server.

I do have a class in my project that contains a function to return the current URL which I am trying to use but I can't figure out how to reference this class/function in an expression:

For example, I have a class called myFunctions.vb with a method called getUrl
I have tried adding a reference to it but I get the error: myFunctions.vb is not defined
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40311923
Ow okay, in that case I think the ReportServerURL doesn't return anything at all...

Would it be an option to add a hidden parameter to the report and pass the result of your getUrl function into it?  As far as I'm aware (I usually don't use local reports) technically this should be possible.
0
 

Author Comment

by:BrianFord
ID: 40311931
yes that would be an option, but that's what I can't figure out how to do :)
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40311952
The VB code would go something like this:

Dim param As New ReportParameter("TheReportParamName", getUrl())
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {param})

Open in new window

Ref LocalReport.SetParameters Method
0
 

Author Comment

by:BrianFord
ID: 40313250
Thanks guys, I finally got this to work so the hyperlink actually loads the required page now.

I'm currently using this expression:
=Parameters!pURL.Value & "/main.aspx?contactID=" & Fields!contactID.Value

Open in new window


which yields the text: http://localhost:49856/main.aspx?contactID=21 and the action works great.

However, I would much rather it just displayed the word 'Select' in the link instead of a long URL, just like a normal html hyperlink
0
 

Author Comment

by:BrianFord
ID: 40314128
any ideas how to do this
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 2000 total points
ID: 40314198
"However, I would much rather it just displayed the word 'Select' in the link instead of a long URL, just like a normal html hyperlink"

I'm not sure what you mean with that.  The action itself doesn't display anything, the text that gets displayed on the report is what is located in the textbox on which the action is defined.  Perhaps you put the URL expression as content for the textbox?  There's no need for that, it can contain anything you like.
0
 

Author Comment

by:BrianFord
ID: 40315504
Sorry, I'm confused and I'm sure I haven't set this up properly but...

The text in the textbox is the expression (=Parameters!pURL.Value & "/main.aspx?contactID=" & Fields!contactID.Value) that creates the url address that I want to Jump To

So design time looks like this:
Design Time
And when the report runs it looks like:
Run time
0
 

Author Closing Comment

by:BrianFord
ID: 40315773
Got it working based on your responses.

Thank you very much for your help
0
 
LVL 37

Expert Comment

by:ValentinoV
ID: 40316358
Nice to hear, good luck with the project!

VV
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to use Variables  and Custom code in SSRS report and Assembly reference to use compile shared code in SSRS. Its big question for all who are working with SSRS. It is easy to create assembly and refer in SSRS report, still there are some steps…
Hi All, I am here to write a simple article to move SSRS (SQL Server Reporting Services) reports from one server to another. When I have faced the same issue to move reports those were developed by developer on development server and now need to …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question