如何启动电子邮件客户端上LinkBut​​ton的点击事件? [英] How to launching email client on LinkButton click event?

查看:175
本文介绍了如何启动电子邮件客户端上LinkBut​​ton的点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以启动一个Outlook电子邮件窗口(类似于邮寄地址:确实在超链接)?

How can I launch an Outlook email window (similar to what mailto: does in a hyperlink) ?

这需要在一个的LinkBut​​ton 单击事件做了。

This needs to be done in a LinkButton click event.

推荐答案

认为的mailto功能是一个函数,需要做的客户端。你将需要JavaScript来做到这一点。根据当你想要的邮寄地址,以发生在你有两个选择。

Consider that the mailto functionality is a function that needs to happen client side. You are going to need javascript to do it. Depending on when you want the mailto to happen you have two choices.

如果你想让它尽快的LinkBut​​ton被点击的结果,那么只需添加到的LinkBut​​ton 的OnClientClick 事件:

If you want it to happen as soon as the LinkButton is clicked then just add to the LinkButton's OnClientClick event:

<asp:LinkButton runat="server" ID="btnEmail" Text="Send Email"
    OnClientClick="window.open('mailto:someone@somewhere.com','email');">
</asp:LinkButton>

如果你希望它发生在服务器端code的运行将有丝了JavaScript事件运行时,新的页面启动:

If you want it to happen AFTER the server side code has run your are going to have wire up the javascript event to run when the new page starts up:

// At the end of your LinkButton server side OnClick event add the following code:
ClientScript.RegisterStartupScript(this.GetType(), "FormLoading",
    "window.open('mailto:someone@somewhere.com','email');", true);

希望有所帮助。

Hope that helps.

这篇关于如何启动电子邮件客户端上LinkBut​​ton的点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆