![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 12
OS: Windows XP
|
Mailto link from database field
Hello,
I am trying to use the mailto function to pull in the email address from a SQL table and I don't know what I am missing as far as the syntax and coding. Here is what I have: <a href="mailto:dr["Email"] ">" + dr["Email"] .ToString() + "</a> Thanks |
|
|
|
|
|
#2 (permalink) |
|
TSF Enthusiast
|
Re: Mailto link from database field
What preprocessor are you using? Where is the rest of your source?
__________________
Antec Neo Power 500W, ABIT IP35-E, Intel E2180@2.66Ghz, Corsair XMS2 2x1GB DDR2-800, PNY 8800GT, 320GB Seagate * lazy college student alert *- If I've inadvertently ignored a thread, please Let me know about it Have I helped you solve your problem? Donate to Techsupportforums Klart Skepp!
|
|
|
|
|
|
#3 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 12
OS: Windows XP
|
Re: Mailto link from database field
Here is the entire code:
Code:
using System.Web.UI.HtmlControls;
namespace HSI
{
public partial class ourpeople_workercomp : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LoadWC();
}
private void LoadWC()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
DataTable dt = Utils.GetDataTableForUI("dbo.WorkersCompEmpSEL", null);
foreach (DataRow dr in dt.Rows)
{
sb.Append("<li>" + dr["EmployeeName"] .ToString() + ", " + dr["EmployeeTitle"] .ToString() + "<br>" + dr["Phone"] .ToString() + "<br>" + dr["Email"] .ToString() + "<br>" + dr["Location"] .ToString() + "</li>");
}
this.workersUL.InnerHtml = sb.ToString();
}
}
}
|
|
|
|
|
|
#4 (permalink) |
|
TSF Enthusiast
|
Re: Mailto link from database field
Ah, ok, I'm not a .net or ASP guy, but perhaps you need to concatenate the email address variable with the beginning of the tag. What output do you get with the way you have it currently?
__________________
Antec Neo Power 500W, ABIT IP35-E, Intel E2180@2.66Ghz, Corsair XMS2 2x1GB DDR2-800, PNY 8800GT, 320GB Seagate * lazy college student alert *- If I've inadvertently ignored a thread, please Let me know about it Have I helped you solve your problem? Donate to Techsupportforums Klart Skepp!
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 12
OS: Windows XP
|
Re: Mailto link from database field
What I get now on the page is I get a link and when you hover over it at the bottom right corner of the browser it says mailto:dr[. When you click on the link it opens a new message email and in the To field it says dr[.
|
|
|
|
|
|
#6 (permalink) |
|
TSF Enthusiast
|
Re: Mailto link from database field
Yup, that's because you haven't enclosed the variable.
You should try changing this : Code:
<a href="mailto:dr["Email"] ">" + dr["Email"] .ToString() + "</a> Code:
<a href="mailto:"+dr["Email"] +">"+dr["Email"] .ToString()+"</a> Let me know if you have success with this.
__________________
Antec Neo Power 500W, ABIT IP35-E, Intel E2180@2.66Ghz, Corsair XMS2 2x1GB DDR2-800, PNY 8800GT, 320GB Seagate * lazy college student alert *- If I've inadvertently ignored a thread, please Let me know about it Have I helped you solve your problem? Donate to Techsupportforums Klart Skepp!
|
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 12
OS: Windows XP
|
Re: Mailto link from database field
I think we are closer but what happens now when I use your updated code is that the a href seems to be missing something. The quotes between the open tag of the a href and closing tags don't match up. This is what I have right now.
"<br>"<a href="mailto:"+dr["Email"] +">"+dr["Email"] .ToString()+"</a><br>" Something seems to be missing in this code. |
|
|
|
|
|
#8 (permalink) |
|
Registered User
Join Date: May 2008
Posts: 12
OS: Windows XP
|
Re: Mailto link from database field
I figured it out. The code should look like this:
"<br><a href='mailto:" + dr["Email"] .ToString() + "'>" + dr["Email"] .ToString() Fox, thanks for your help on this. I appreciate it. |
|
|
|
|
|
#9 (permalink) |
|
TSF Enthusiast
|
Re: Mailto link from database field
Ah, ok, I think you are missing some quotation marks. You'll need to escape some of them. I do not know how to do it for this language (this is asp, right?), but I would expect it's a \ or something. Also, the " between <br> and <a href seems like it's extraneous.
If the escaped characters work with a slash, it might look something like this: Code:
"<br><a href=\"mailto:\""+dr["Email"] +"\">"+dr["Email"] .ToString()+"</a><br>"
__________________
Antec Neo Power 500W, ABIT IP35-E, Intel E2180@2.66Ghz, Corsair XMS2 2x1GB DDR2-800, PNY 8800GT, 320GB Seagate * lazy college student alert *- If I've inadvertently ignored a thread, please Let me know about it Have I helped you solve your problem? Donate to Techsupportforums Klart Skepp!
|
|
|
|
![]() |
| Thread Tools | |
|
|