Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable into Mailto 1

Status
Not open for further replies.

sila

Technical User
Aug 8, 2003
76
0
0
GB
Hi
I'm getting an email address out of a database using the following....

Code:
Me.SqlConnection1.Open()
        dtrCabinetEmail = Me.SqlComm_SelectCabinetEmail.ExecuteReader
        If dtrCabinetEmail.Read Then
            Email = dtrCabinetEmail("committee_email")
            Me.lblEmail.Text = "" & Email & ""
        End If
        Me.SqlConnection1.Close()

I'm then trying to read the value into a mailto doing this on the aspx side...

Code:
<a href=mailto:<asp:Label id="lblEmail" runat="server"></asp:Label></a>
Its not working - but then I don't know what I'm doing! Any help appreciated.

Thanks
 
Easiest way is to not use a Label. Instead use a LiteralControl (or a hyperlink control may be better suited depending on what you are doing.). Anyway, here's an example using a Literal Control:
Code:
<asp:Literal id="Literal1" runat="server"></asp:Literal>
and to populate it:
Code:
Literal1.Text = "<a href=""mailto:me@here.com"">Email Me</a>"

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
The part where you have me@here.com is where the value will be changing for various email addresses, does what you have given me above cover that? If my email variable is called MemberEmail, where would it go?

Thanks
 
You would just set the Text property like any other string variable as that is all it is:
Code:
        Dim MemberEmail As String = "me@here.com"
        Literal1.Text = "<a href=""mailto:" & MemberEmail & """>Email Me</a>"

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top