n_srikanth4
asked on
URL Encoding in SSRS for Ampersand (&) and Apostrophe(')
Hi Experts:
I have set the Assembly Refernce to "System.Web" , have written the Custom Function "URLEncode" (using VB) and used the function in the Report Expression using the keyword "Code" as per the link below.
http://capstonebi.blogspot.com/2010/04/url-encoding-in-reporting-services.html
I am almost there . The code is working for most of the special Characters excluding the Apstrophe ( ' ) and Ampersand (& )
Could you please provide me the custom code (using VB ) or Correct the code posted in the link above , so that it works for even Apstrophe ( ' ) and Ampersand (& ) as well.
I will really appreciate your reply .
Kind Regards,
Sreekanth.
I have set the Assembly Refernce to "System.Web" , have written the Custom Function "URLEncode" (using VB) and used the function in the Report Expression using the keyword "Code" as per the link below.
http://capstonebi.blogspot.com/2010/04/url-encoding-in-reporting-services.html
I am almost there . The code is working for most of the special Characters excluding the Apstrophe ( ' ) and Ampersand (& )
Could you please provide me the custom code (using VB ) or Correct the code posted in the link above , so that it works for even Apstrophe ( ' ) and Ampersand (& ) as well.
I will really appreciate your reply .
Kind Regards,
Sreekanth.
The code in the link is encoding the & as %26.
Also try the URLPathEncode function.
ASKER
Hi CodeCruiser:
Can you please give me an example VB code to encode & and ' .
Regards,
Sreekanth.
Can you please give me an example VB code to encode & and ' .
Regards,
Sreekanth.
As I said above, & is being encoded to %26. How else do you want to encode it?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
What URL do you have in inURL and what do you get in outURL?
ASKER
Hi CodeCruiser :
Please See the code below (used in the Report Expression ) where I have used "URLEncode" VB function
="javascript:void(window.o pen('http://iisau182dev68.appdev.corptst.anz.com/ReportServer/Pages/ReportViewer.aspx?/ARMD/Trend_Analysis_Issues_Raised_by_Issue_Rating_Detail&rs:Command=Render&rc:Parameters=false&rc:HeaderArea=None&Start_Date="+For mat(Parame ters!Start _Date.Valu e,"dd/MM/y yyy")
+"&Division="+Code.URLEnco de(join(Pa rameters!D ivision.Va lue,"&Divi sion="))
+"&Management_Awareness_Ra ting="+Cod e.URLEncod e(join(Par ameters!Ma nagement_A wareness_R ating.Valu e,"&Manage ment_Aware ness_Ratin g="))
+"&Report_Rating="+Code.UR LEncode(jo in(Paramet ers!Report _Rating.Va lue,"&Repo rt_Rating= "))
+"&BU="+Code.URLEncode(joi n(Paramete rs!BU.Valu e,"&BU="))
+"&End_Date="+Format(Param eters!End_ Date.Value ,"dd/MM/yy y")
+"&Division_Owned_And_Allo cated="+Pa rameters!D ivision_Ow ned_And_Al located.Va lue
+"&Audit_Manager="+Code.UR LEncode(Jo in(Paramet ers!Audit_ Manager.Va lue, "&Audit_Manager="))
+"&Issue_Owner="+Code.URLE ncode(Join (Parameter s!Issue_Ow ner.Value, "&Issue_Ow ner="))
+"&Issue_Rating="+Fields!I ssue_Ratin g.Value
+"&Country="+Code.URLEncod e(join(Par ameters!Co untry.Valu e,"&Countr y="))
+"&Region="+Code.URLEncode (join(Para meters!Reg ion.Value, "&Region=" ))
+"&Month_And_Year="+ FORMAT(Fields!ACTISSUEDATE .Value,"MM M-yy")+"', 'ChildW',' toolbar=ye s,location =yes,direc tories=yes ,status=ye s,menubar= yes,resiza ble=yes,sc rollbars=y es'))"
Note : Here I am passing Multi Value parameters where I am using the function “Join” and it works absolutely fine for all the special characters excluding Ampersand and Apostrophe.
Question : How to encode the Ampersand(&) and Apostrophe (‘) and pass through the query string URL where I need to escape these characters.
I appreciate your Immediate reply.
Regards,
Sreekanth.
Please See the code below (used in the Report Expression ) where I have used "URLEncode" VB function
="javascript:void(window.o
+"&Division="+Code.URLEnco
+"&Management_Awareness_Ra
+"&Report_Rating="+Code.UR
+"&BU="+Code.URLEncode(joi
+"&End_Date="+Format(Param
+"&Division_Owned_And_Allo
+"&Audit_Manager="+Code.UR
+"&Issue_Owner="+Code.URLE
+"&Issue_Rating="+Fields!I
+"&Country="+Code.URLEncod
+"&Region="+Code.URLEncode
+"&Month_And_Year="+ FORMAT(Fields!ACTISSUEDATE
Note : Here I am passing Multi Value parameters where I am using the function “Join” and it works absolutely fine for all the special characters excluding Ampersand and Apostrophe.
Question : How to encode the Ampersand(&) and Apostrophe (‘) and pass through the query string URL where I need to escape these characters.
I appreciate your Immediate reply.
Regards,
Sreekanth.
ASKER
Hi CodeCruiser:
No it doesn't work for me .. I need a custom function , encodes the Ampersand(&) and Apostrophe (‘) and pass through the query string URL (like '&' is encoded as %26 ) and escape these characters while passing through the query string.
Could you please resolve this query . I appreciate your immediate reply.
Regards,
Sreekanth.
No it doesn't work for me .. I need a custom function , encodes the Ampersand(&) and Apostrophe (‘) and pass through the query string URL (like '&' is encoded as %26 ) and escape these characters while passing through the query string.
Could you please resolve this query . I appreciate your immediate reply.
Regards,
Sreekanth.
The trouble is that & is encoded by the EncodeURL but the apostrophe is probably not so its problamatic with SQL Server. One way could be
Public Function UrlPathEncode (ByVal inURL As String) As String
Dim outURL As String
outURL = System.Web.HttpUtility.Url PathEncode (inURL).To String
Return outURL.Replace("'", "''")
End Function
Public Function UrlPathEncode (ByVal inURL As String) As String
Dim outURL As String
outURL = System.Web.HttpUtility.Url
Return outURL.Replace("'", "''")
End Function
ASKER
good