Relative URL in ReportViewer Action

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?
BrianFordAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ramkisan JagtapLead DeveloperCommented:
I think relative path is not supported in the ReportViewer, So please write some custom code and create and  add URL from there.
0
ValentinoVBI ConsultantCommented:
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
BrianFordAuthor Commented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ValentinoVBI ConsultantCommented:
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
BrianFordAuthor Commented:
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
ValentinoVBI ConsultantCommented:
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
BrianFordAuthor Commented:
yes that would be an option, but that's what I can't figure out how to do :)
0
ValentinoVBI ConsultantCommented:
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
BrianFordAuthor Commented:
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
BrianFordAuthor Commented:
any ideas how to do this
0
ValentinoVBI ConsultantCommented:
"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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BrianFordAuthor Commented:
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
BrianFordAuthor Commented:
Got it working based on your responses.

Thank you very much for your help
0
ValentinoVBI ConsultantCommented:
Nice to hear, good luck with the project!

VV
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.