Monday, March 12, 2012

Issue with URL Encoding report's hyperlink value.

Hello,

I've created a hyperlink in a report. The hyperlink action is 'Jump to URL' The URL is http://ServerName/SomePage.aspx?AccountCode=####&InvoiceLevel=1

The hyperlink works just fine in the designer, it's value becomes http://ServerName/SomePage.aspx?AccountCode=%23%%23%%23%%23&InvoiceLevel=1, however when I run from the web the report's URL is not properly URL encoded. It's value is http://ServerName/SomePage.aspx?AccountCode=#%23%23%23&InvoiceLevel=1 which is incorrect since the browser now treats the # as a hash.
I've tried explicitly URL Encoding the #### in the function but the report returns an error. "http://ServerName/SomePage.aspx?AccountCode=" + System.Web.HttpUtility.UrlEncode(####) + "&InvoiceLevel=1"

I've tried it in RS2000 & RS2005, same results.

Help..Idea
Robert.

Hi Robert,

It looks like the first pound sign (number sign, hash, tic-tac-toe, octothrope... call it what you will) is being interpreted as a URL anchor symbol.

Is the "access" param always literally "####"? If so it should work if you URLEncode yourself by typing "%23%23%23%23".

If the access param is dynamic and may or may not begin with a #, you could use the Replace function in an expression to encode any #'s.

-Chris|||

Thanks for your reply,

The AccountCode parameter value is dynamic and for the most part as meaningful data, however the data originates from the mainframe so there are values that start with #. I could encode it using the replace however the Accountcode could contain all possible characters. Any other suggestions.

Robert.

|||

Try using the UrlEncode function on the argument value, e.g.:

=Globals!ReportServerUrl+ "?" & Globals!ReportFolder & "/Report&Parameter=" &
System.Web.HttpUtility.UrlEncode(Fields!AccountID.Value)

See also MSDN:
http://msdn2.microsoft.com/en-us/library/system.web.httputility.urlencode.aspx

-- Robert

|||

I tried using System.Web.HttpUtility.UrlEncode. Look at my first post. It works in the designer but not in Report Manager. It's very easy to recreate. Here are the steps:

Add a new blank report to a project.

Drop on a text box and set the expression to System.Web.HttpUtility.UrlEncode("####")

click report properties, click the reference tag and add System.web.

Preview the report in the designer. It works just fine.

Deploy the report and then view it in Report Manager. It displays #errror. I suspected the Report Server is not able to find System.web.dll

Robert.

|||

Did you ever resolve this problem, as I've just hit it!

No comments:

Post a Comment