URLEncode Use Examples
In this example, we are going to look at the Manage Payment Profiles WebPart. This WebPart displays an Iframe that contains payment methods and it uses URLEncode to remove special characters from an encrypted string of parameters being passed to the IFrame window.
The Payment Pad section has an onload process. In this process we are running an Encrypt service that is encrypting a set of parameters that will then be passed in the URL of the IFrame. After the Encrypt service, we are running the URLEncode service and this takes the encrypted string and replaces special characters that may cause issues in a url and replaces them with a % sign followed by the special characters hexcode. Finally, the SetControlProperty service is setting the HTML of the HtmlGenericControl field on the webpart canvas.
Below you can see how the UrlEncode service is replacing special characters with their hexcode. ( / is turned into %2f and + is turned into %2a).
Finally, the SetControlProperty sets the HTML of the HTMLGenericControl and creates an IFrame of EP_ProcessPayment.aspx and we pass the encrypted and encoded parameters to the IFrame as a querystring of EP_Params.