Method 1. Use the <a> label,
Front-end:
Copy codeThe Code is as follows:
<A href = '<% # "OrigImageShow. aspx? Id = 1 & image_id = "+ Eval (" ID ") %> 'id =" tb_search "runat =" server "target =" _ blank "> pop-up </a>
<A href = 'javascript: alert ("<% # OrigImageShow. aspx? Image_id = "+ Eval (" ID ") %>") '> displayed </a>
Use the <a> label and do not refresh the Home Page
Method 2. asp: HyperLink
(1) Foreground: <asp: HyperLink ID = "hyperLink" runat = "server" Text = '<% # Eval ("OperationFlag ") %> 'target = "_ blank"> </asp: HyperLink>
Backend binding path:
Copy codeThe Code is as follows:
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"); // obtain the parameter to be passed through the hidden field
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 = "pop-up" Target = "_ blank"> </asp: HyperLink>
When asp: HyperLink is used, the page does not refresh the homepage.
Method 3.asp: LinkButton
(1) Foreground: <asp: LinkButton ID = "tb_searchori" runat = "server" Text = "pop-up" OnClientClick = <% # "window. open ('origimageshow. aspx? Image_id = "+ Eval (" id ") +" ') "%> </asp: LinkButton>
(2) Foreground: <asp: linkButton ID = "tb_searchori" runat = "server" Text = "pop-up" OnClick = "LB_Ori_Click" CommandArgument = '<% # Bind ("ID ") %> '> </asp: LinkButton>
Copy codeThe Code is as follows:
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> ");
}
Use asp: LinkButton to refresh the homepage after the page is displayed.
To sum up, we recommend Using HyperLink or.