方法1.使用<a>标签,
前台:
复制代码代码如下:
<a href='<%# "OrigImageShow.aspx?id=1&image_id="+Eval("ID")%>' id="tb_search" runat="server" target="_blank"> 弹出 </a>
<a href='Javascript:alert("<%# OrigImageShow.aspx?image_id=" + Eval("ID")%>")'>弹出</a>
使用<a>标签,不刷新主页面
方法2.:asp:HyperLink
(1)前台:<asp:HyperLink ID="hyperLink" runat="server" Text='<%# Eval("OperationFlag") %>' Target="_blank" ></asp:HyperLink>
后台绑定路径:
复制代码代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink btnlink = (HyperLink)e.Row.Cells[3].FindControl("hyperLink");
HiddenField hidderid = (HiddenField)e.Row.Cells[3].FindControl("log_id");//通过隐藏域获取要传递的参数
string url = string.Empty;
if (hidderid != null)
{
url = "~/ImageManage/LogPicDetails.aspx?id=" + hidderid.Value;
btnlink.NavigateUrl = url;
}
}
}
(2)<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "OrigImageShow.aspx?image_id=" + Eval("ID")%>'
Text="弹出" Target="_blank"></asp:HyperLink>
使用asp:HyperLink ,弹出页面不刷新主页面
方法3.asp:LinkButton
(1) 前台:<asp:LinkButton ID="tb_searchori" runat="server" Text="弹出" OnClientClick=<%#"window.open('OrigImageShow.aspx?image_id="+Eval("id")+"')" %> ></asp:LinkButton>
(2) 前台:<asp:LinkButton ID="tb_searchori" runat="server" Text="弹出" OnClick="LB_Ori_Click" CommandArgument='<%#Bind("ID") %>' ></asp:LinkButton>
复制代码代码如下:
protected void LB_Ori_Click(object sender, EventArgs e)
{
LinkButton lbtn = (LinkButton)sender;
int imgID = int.Parse(lbtn.CommandArgument.ToString());
string url = "OrigImageShow.aspx?image_id=" + imgID;
url = Page.ResolveUrl(url);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "messid", "<script language='javascript'>window.open('" + url + "');</script>");
}
使用asp:LinkButton,弹出页面后刷新主页面
综上所述:推荐使用HyperLink或者a的方式