urlEncode parameter value for hyperlink

Stimulsoft Reports.WEB discussion
Post Reply
kevin163
Posts: 27
Joined: Fri Oct 17, 2014 9:18 am

urlEncode parameter value for hyperlink

Post by kevin163 »

i have a report,it need a hyperlink. the field's value may have some char like & space etc. so i need to urlencode the value.

i set the getHyperLink event to do this purpose

Code: Select all

public void DataText2_GetHyperlink(object sender, Stimulsoft.Report.Events.StiValueEventArgs e)
        {
            // CheckerInfo: GetHyperlinkEvent DataText2
            e.Value = "http://www.baidu.com?a="+System.Web.HttpUtility.UrlEncode(up_rpt_PurchaseTypeSum.itemcategroryname);
        }
when i preview the report,it tell me
The error of compilation is found in the 'GetHyperlink' event of the 'DataText2' component:
there is no class “HttpUtility” in namespace “System.Web”

what should i do to reference the System.Web.Dll?
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: urlEncode parameter value for hyperlink

Post by HighAley »

Hello.

Please add reference on System.Web assembly to the report. You could do this with next code:

Code: Select all

List<String> refs = new List<string>(report.ReferencedAssemblies);

if (!refs.Contains("System.Web.Dll"))
{
    refs.Add("System.Web.Dll");
}
report.ReferencedAssemblies = refs.ToArray();
Thank you.
Post Reply