Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with combining encodeURIComponent() with Mailto (Gridview)

Posted on 2014-01-22
3
Medium Priority
?
536 Views
Last Modified: 2014-03-26
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?
0
Comment
Question by:andyw27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 39802778
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

0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 total points
ID: 39802857
A server-side solution using the bound data would be to replace line 3 of your posted code to:
<a href='mailto:<%# Eval("email") %>?Subject=<%# Server.UrlEncode("Notification " & Eval("Number") & " - " & Eval("Description"))%>'>

Open in new window

0
 

Author Comment

by:andyw27
ID: 39847397
Thanks for the suggestions, I'll give this a go.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question