2017-03-02 99 views
0

1)如何检测中间点击链接鼠标滚轮而不是右/左击?中鼠标点击链接打开新标签只有ASP C#

2)行为应该是新的选项卡,鼠标中键点击链接,如果点击左键,则重新加载到同一页面。 (与Chrome相同)。

3)ASP.Net,C#和链接是GridView中第一个选择链接列。 GridView的第一列选择链接:

enter image description here

感谢。

+0

通过Asp.Net您的意思是Web窗体? – Emad

+0

是的网站版本不是MVC – cpeterson

回答

1

你可以在你的JavaScript

function fixWhich(e) { 
    if (!e.which && e.button) { 
    if (e.button & 1) e.which = 1  // Left 
    else if (e.button & 4) e.which = 2 // Middle 
    else if (e.button & 2) e.which = 3 // Right 
    } 
} 
1

使用Web窗体其实你可以使用服务器端检测到这一点。你可以这样做:

private void mouseClick(object sender, MouseEventArgs e) 
{ 
    if (e.Button == MouseButtons.Middle) 
    {  
     //Open new window 
    } 
    else 
    { 
     //Open on the same window 
    } 
} 

但很难在服务器端,打开新的窗口,我很害怕。所以最好使用客户端。

+0

因为MouseEventArgs用于Windows窗体,所以不能在ASP.net中运行谢谢。 – cpeterson

相关问题