Advertisement

02.27.2004 at 08:12AM PST, ID: 20900293
[x]
Attachment Details

ASP.NET/Repeater/Hyperlink/Mailto: Implementing a databound mailto hyperlink in a repeater

Asked by rgrimm in .NET

Tags: hyperlink, mailto, repeater

I have a repeater control that contains an hyperlink control bound to a field in a datareader. I want the user to be able to click the hyperlink and have it launch an email on their system. This would mean using href=mailto:name@domain.com syntax in the hyperlink. The code below correctly displays a clickable hyperlink in the repeater:

<asp:HyperLink ID="MailTo" Runat=server NavigateUrl='mailto:<%# Databinder.Eval(Container.DataItem, "Email") %>' text='<%# Databinder.Eval(Container, "DataItem.Email") %>'></asp:HyperLink>

However, when you click the link Microsoft Outlook gives the following error:

Cannot start Microsoft Outlook. The command line argument is not valid. Verify the switch you are using.

This is no doubt due to string that they hyperlink control presents to Outlook:  

mailto:<%# Databind.Eval(Container.DataItem, "Email) %>

It doesn't look like an email address to me either. So I need to get the expression converted to a proper email address string. How do I do it?
Start Free Trial
[+][-]02.27.2004 at 08:29AM PST, ID: 10470502

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: .NET
Tags: hyperlink, mailto, repeater
Sign Up Now!
Solution Provided By: PhilipRocks
Participating Experts: 1
Solution Grade: A
 
 
[+][-]02.27.2004 at 09:27PM PST, ID: 10474729

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32