[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 290
  • Last Modified:

How can I create an email hyperlink from the database data?

I have a site that stored content in a field, and this content display on the screen. How can I make email hyperlink from the database?

here is the code  have:
<asp:Hyperlink ID="lblEmail"  NavigateUrl='<%#Eval("Email_Name", "mailto:{0}") %>' Text='<%# Eval("Email_Name", "Send an Email to {0}") %>' runat="server" /></td></tr>
 
I tried this too and it doesent seem to work.
 
<asp:HyperLink ID="lblEmail" NavigateUrl='mailto:<%# Eval("Email_Name") %>' runat="server" ></asp:HyperLink>

Open in new window

0
Romacali
Asked:
Romacali
  • 3
  • 3
  • 3
2 Solutions
 
dawn_319Commented:
I ran into this problem and ended up using html
<a href="mailto:<%#eval("DCEmail") %>" target="_blank" ><%# eval("DCName")  %></a>

Open in new window

0
 
wht1986Commented:
<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("UserName") %>' NavigateUrl='<%# Eval("Email_Name","mailto://{0}") %>' />
0
 
RomacaliAuthor Commented:
I tried the HTMl and I got this:
pointing to:
Line 23: <tr><td><asp:Label ID="lblEmail" runat="server" ><a href="mailto:<%#eval("Email_Name") %>" target="_blank" ><%# eval("Email_Name")  %></a></asp:Label>


The error I get:

Compiler Error Message: CS0103: The name 'eval' does not exist in the current context

Source Error:

 
 
 
Line 21: <tr><td><asp:Label ID="lbltitle" runat="server" /></td></tr>
Line 22:
Line 23: <tr><td><asp:Label ID="lblEmail" runat="server" ><a href="mailto:<%#eval("Email_Name") %>" target="_blank" ><%# eval("Email_Name")  %></a></asp:Label>
Line 24: </td></tr>
 

 

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
wht1986Commented:
it's case sensitive, change eval to Eval on dawns method

also give this a try, as a single control version

<asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Eval("Email_Name") %>' NavigateUrl='<%# Eval("Email_Name","mailto://{0}") %>' />
0
 
dawn_319Commented:
wht1986: When is it case sensitive?  I have it running with lowercase.
I do agree that a singe control version is a better solution.
0
 
RomacaliAuthor Commented:
still not working
0
 
dawn_319Commented:
Perhaps we need to see a bit more of your code... are you using this in a gridview, formview, detailsview???
0
 
RomacaliAuthor Commented:
I think I need to add a gridview.. thanks
0
 
wht1986Commented:
yes both those solutions above only work inside a databound control, gridview, listview, etc bound to a datasource
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now