Launching Client Email with ASP value with LinkButton

Matt Bergevin

This one has been giving me trouble all morning and I hope someone with more ASP knowledge can help me! I didn't build this app, I inherited it and it was built in .NET 2.0.

I'm upgrading an app that generated a list of href=mailto. Now it needs to run some C# code so I started recreating these as linkButtons. I was following this article How to launching email client on LinkButton click event? but I have one more step.

<asp:Repeater DataSourceID="sdsUserList" runat="server">
    <ItemTemplate>
        <li>
            <asp:LinkButton ID="lbEmail" runat="server" Text='<%# Eval("UserName") %>' OnClientClick="window.open('mailto:<%# Eval("UserEmail") %>', 'email')" OnClick="lblEmail_Click" />
        </li>
    </ItemTemplate>
</asp:Repeater>

I need the OnClientClick to simply open up a new email to send to the User. I've monkeyed around with the quotes but the error I am getting is "The server tag is not well formed".

deebs

It could be the quotes for your OnClientClick. You'll need to change this:

OnClientClick="window.open('mailto:<%# Eval("UserEmail") %>', 'email')"

You could try calling a function with the Eval statement as a parameter. For example:

OnClientClick='<%# String.Format("javascript:return SendEmail(\"{0}\")", Eval("UserEmail").ToString()) %>'

<script type="text/javascript">
    function SendEmail(email){
        window.open("mailto:" + email);
    }

</script>

I think there are other ways to escape the quotes too, but that's just a possible quick fix. This I just tested and it works fine. Good luck!

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Launching Client Email with ASP value with LinkButton

From Dev

Launching email client programatically in android and passing email address to client

From Dev

ASP.NET Not getting CommandArgument Value from LinkButton onClick(VB)

From Dev

Email client support negative margin value?

From Dev

Email client support negative margin value?

From Dev

Conditionally show hide asp linkbutton

From Dev

Open asp LinkButton in a new tab

From Dev

Make asp:LinkButton behave like asp:button

From Dev

update linkbutton text dynamically in asp.net

From Dev

asp LinkButton inside html Button tag

From Dev

ASP.Net LinkButton works local but not on Server

From Dev

ASP.NET and ListView control having LinkButton

From Dev

showing Jquery ui datepicker on click of asp:linkbutton

From Dev

ASP.NET LinkButton not invoking 'OnCommand' event

From Dev

<asp:LinkButton> make partial text italics

From Dev

asp:LinkButton, how to cancel OnClick event?

From Dev

I need to show table row on asp linkbutton

From Dev

Calling 2 functions using asp:linkButton

From Dev

linkbutton onclick event not firing in asp net

From Dev

Can't get the text value of linkbutton in gridview

From Dev

Can't get the text value of linkbutton in gridview

From Dev

pass the value to code behind onclick of linkButton

From Dev

put list of email as Bcc in a link mailto tag (List in asp.net mvc model) Client side

From Dev

eMail Client Compatible with Yahoomail

From Dev

Detecting email client of the recipients

From Dev

Send user to their email client

From Dev

eMail Client Compatible with Yahoomail

From Dev

Email Client with Vim Editing

From Dev

Ubuntu terminal email client

Related Related

HotTag

Archive