0
votes

i have a hyperlink in grid view. i want to open a new window when i click on hyper link. i am able to open a new window. but modal popup is also open along with this. Popup should not be open when i click on hyperlink. it should be open when i click on row. not hyperlink which is part of grid view row.

protected void GridView_RowDataBound(object sender, 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 data) { //InForce JumpTo HyperLink jumpToPol= e.Row.FindControl("JumpTopol") as 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;
                }
            }
        }
1

1 Answers

0
votes

Which click event gets fired first? You can check in your JavaScript if the hyper link has been clicked, and if yes then suppress the click event of the row.

It's a bit weird though... to have hyperlinks in the row and attach a click even to the entire row as well..