如何在网格视图中每次单击按钮或链接时打开不同的新弹出窗口

how to open a different new pop window every time a button or link is clicked in a grid view

本文关键字:链接 窗口 新弹出 按钮 网格 视图 单击      更新时间:2023-09-26
protected void gvPendingBinds_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        Label lblID = (Label)e.Row.FindControl("lblID");
        HyperLink hlOpen = (HyperLink)e.Row.FindControl("hlOpen");
        HyperLink hlEmail = (HyperLink)e.Row.FindControl("hlEmail");
        if (hlEmail.Text != "")
        {
            hlEmail.ToolTip = "Click to open email client with lead loaded";
            hlEmail.NavigateUrl = "mailto:" + hlEmail.Text + "?Subject=Business Insurance quote";
            hlEmail.Style.Add("Cursor", "pointer");
        }
        hlOpen.ToolTip = "Open more details";
        hlOpen.Attributes.Add("onclick", "javascript: window.open('LeadDetails.aspx?id=" + lblID.Text + "', 'window','HEIGHT=800,WIDTH=820,top=50,left=50,toolbar=no,scrollbars=yes,resizable=yes').focus();return true;");            
        hlOpen.Style.Add("Cursor", "pointer");            
    }
} 

每次单击不同行的超链接时,我都会打开相同的弹出窗口,其中包含不同的数据。我的客户希望打开多个窗口,以便在每次单击网格中的不同链接时查看多个潜在客户的数据。

看起来你走在正确的轨道上。尝试使用 _blank 作为窗口的名称:

hlOpen.Attributes.Add("onclick", "javascript: window.open('LeadDetails.aspx?id=" + lblID.Text + "', '_blank','HEIGHT=800,WIDTH=820,top=50,left=50,toolbar=no,scrollbars=yes,resizable=yes').focus();return true;");