我想在按钮点击事件中打开页面新标签。这是我的代码:
<asp:ImageButton ID="imgPropertyImage" CommandArgument='<%#Eval("pro_id") %>'
runat="server" Height="90px" Width="130px" CssClass="imgborder"
ImageUrl='<%#Eval("display_photo") %>' OnCommand="imgPropertyImage_Command"
BorderColor="#00CCCC" AlternateText="" onclick="imgPropertyImage_Click" />
protected void imgPropertyImage_Click(object sender, ImageClickEventArgs e)
{
ImageButton img = sender as ImageButton;
Session["Pro-ID"] = img.CommandArgument;
Response.Redirect("PropertyDetails.aspx");
}
答案 0 :(得分:1)
将此javascript放在您的asp:content
中 <script type="text/javascript" language="javascript">
var windowObjectReference;
function openRequestedPopup() {
var windowObjectReference = window.open("PropertyDetails.aspx",
"DescriptiveWindowName",
"menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes");
}
</script>
在ImageButton OnClientClick
中OnClientClick="javascript:return openRequestedPopup();"
答案 1 :(得分:0)
首先,删除<a>
标记。
并添加这个:
OnClientClick="aspnetForm.target ='_blank';"/>
在按钮属性中。