0

我想在按钮单击事件中打开页面新选项卡。这是我的代码:

<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");
}
4

2 回答 2

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();"
于 2012-04-16T12:38:19.283 回答
0

首先,删除<a>标签。并添加:

  OnClientClick="aspnetForm.target ='_blank';"/>

在您的按钮属性中。

于 2012-04-16T08:25:46.133 回答