用于打开新窗口的网格视图超链接



我在网格视图中有一个超链接。当我点击超链接时,我想打开一个新窗口。我可以打开一扇新窗户了。但模式弹出窗口也随之打开。当我点击超链接时,弹出窗口不应该打开。当我点击行时,它应该是打开的。而不是作为网格视图行一部分的超链接。

protected void GridView_RowDataBound(对象发送方,GridViewRowEventArgs e){if(e.Row.RowType==DataControlRowType.DataRow){

            SearchResult data = e.Row.DataItem as SearchResult;
             // Add click to open modal 
            e.Row.Attributes.Add("onclick", string.Format("showDetail('{0}','{1}','{2}','{3}');", data.Number, data.System, customerNumber, customer.CustomerNumber));
            // Choose background color
            DefineBackgroundColor(e, data);

            AddAccLink(e, data);

            AddJumpTomain(e, data);
        }
    }

private void AddJumpTomain(GridViewRowEventArgs e,SearchResult数据){//InForce JumpToHyperLink jumpToPol=e.Row.FindControl("jumpToPol")作为HyperLink;

        if (jumpToPolicy != null)
        {

                    string link = string.Format(Configuration.PolUrl, IdentityProvider.CurrentUser.GetUserName(), customerNumber, data.PolNumber);
                    jumpToPol.NavigateUrl = link;
                    //jumpToPol.Attributes.Add("onclick", "javascript:cancelEventPropagation(event);return true;");
                    jumpToPol.Attributes.Add("onclick", "javascript:window.open(" + link + ");return false;");
                }
                else
                {
                    jumpToPol.Visible = false;
                }
            }
        }

哪个点击事件首先被触发?您可以在JavaScript中检查超链接是否已被单击,如果是,则抑制该行的单击事件。

不过这有点奇怪。。。在行中设置超链接,甚至在整行上附加单击。。