要在ASP.Net中使用HyperLinkField弹出窗口,并在Chrome浏览器中正常工作,可以按照以下步骤操作。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLinkField hyperlinkField = (HyperLinkField)e.Row.Cells[0].Controls[0];
hyperlinkField.NavigateUrl = "javascript:void(0);";
hyperlinkField.Attributes["onclick"] = "openPopup('" + DataBinder.Eval(e.Row.DataItem, "ID") + "');";
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = YourDataSource;
GridView1.DataBind();
}
GridView1.RowDataBound += GridView1_RowDataBound;
}
这样,当用户单击HyperLinkField时,将调用JavaScript函数openPopup,并打开一个新的浏览器窗口来显示弹出窗口。在Chrome浏览器中,这种方法应该正常工作。