方法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的方式