简体   繁体   中英

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

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");            

    }
} 

I keep getting the same popup window to open every time I click a different row's hyperlink, with different data. My client want multiple windows to open to view multiple prospect's data each time he clicked a different link in the grid.

It looks like you were on the right track. Try using _blank as the name of your window:

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;");  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM