Page 1 of 1

urlEncode parameter value for hyperlink

Posted: Wed Aug 12, 2015 3:35 am
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?

Re: urlEncode parameter value for hyperlink

Posted: Wed Aug 12, 2015 8:41 am
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.