[英]How I can activate a LinkButton without click on this?
如果我單擊ListView中的按鈕,我想打開Outlook。 怎么...
<a href="mailto:user@example.com">Send email to user@example.com</a>
我有一個 ...
<asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>
沒有網址。 網址從ListView獲取此LinkButton,它可以工作,但在此之后我無法激活此LinkButton :(
怎么...
protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "mailto")
{
int index = Convert.ToInt32(e.CommandArgument);
LinkButton lb = (LinkButton)myListView.Items[index].FindControl("Label2");
string mailto = lb.Text;
LinkButton1.PostBackUrl = "mailto:" + mailto;
LinkButton1.ResolveClientUrl("mailto:" + mailto); //Here?????
}
}
如果不單擊此按鈕,如何激活LinkButton?
嘗試使用<asp:HyperLink />
( 在此處記錄) :
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl = "mailto:abc@example.com" Text ="abc@example.com"></asp:HyperLink>
只需使用鏈接
<asp:HyperLink ID="hl" runat="server" NavigateUrl = ..." Text ="link"></asp:HyperLink>
您可以在后面的代碼中用作鏈接按鈕,但他提供了其他功能
hl.NavigateUrl = "mailto:" + mailto;
塔拉索夫您可以在這里找到所有住宿
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.aspx
使用超鏈接而不是鏈接按鈕
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="mailto:user@example.com" >HyperLink</asp:HyperLink>
如果您堅持使用按鈕,請設置ClientClick屬性。 使用return false;
取消回發。 如果您想要回發,請不要使用。
LinkButton1.ClientClick = "window.open('mailto:someone@somewhere.com', 'email'); return false;";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.