Link to home
Start Free TrialLog in
Avatar of andyw27
andyw27

asked on

Help with combining encodeURIComponent() with Mailto (Gridview)

Hello,

I have the following within a gridview.

<asp:TemplateField>
<ItemTemplate>
<a href='mailto: <%# Eval("email") %> ?Subject=Notification <%# Eval("Number")%> - <%# Eval("Description") %> '>
Send Notification</a>
</ItemTemplate>
</asp:TemplateField>

Open in new window


This kinds of works up until <%# Eval("Description") %> contains a special character, i.e. %

I need to preserve this.  I read this could be done by using encodeURIComponent().  I found an example of this:

<script language="JavaScript"><document.write("<a href=\"mailto:recipient@example.com?subject=" + encodeURIComponent("When, when is now? (if \"now\" is here)") + "\">mail me!</a>")</script>

However I can’t seem to apply it succesfully to my code.  Can anyone help please?
Avatar of leakim971
leakim971
Flag of Guadeloupe image

You can run encodeURIComponent from a console to get the result as it's static :
<script language="JavaScript"><document.write("<a href=\"mailto:recipient@example.com?subject=When%2C%20when%20is%20now%3F%20(if%20%22now%22%20is%20here)\">mail me!</a>")</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andyw27
andyw27

ASKER

Thanks for the suggestions, I'll give this a go.