微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 点击按钮打开新标签?

我想在按钮点击上打开新标签,点击的按钮存在于iframe上.

我用这个代码

string tempabc = "javascript:window.open('ReportViewer.aspx?ReportType=" + rptnew + "&Billno=" + billno + "&Mail=" + "Mail" + "&CCMail=" + CCMail + "&Subject=" + txtSubject.Text + "&MailBody=" + txtMailBody.Text + "')";
ClientScript.RegisterStartupScript(this.GetType(),"script",tempabc,true);

但它不应该显示任何结果.

然后我可以用这个代码

Response.Redirect("ReportViewer.aspx?ReportType=" + rptnew + "&Billno=" + billno + "&Mail=" + "Mail" + "&CCMail=" + CCMail + "&Subject=" + txtSubject.Text + "&MailBody=" + txtMailBody.Text + "'");

它会在同一个iframe上打开下一页.

我可以做什么.

在我的.aspx页面中,我可以使用该标签.

<body>
    <form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:Panel ID="PanelMail" runat="server">
            <asp:UpdatePanel ID="UpdatePanel15" runat="server">
                <ContentTemplate>
                      <table>                    
                         <tr>
                            <td colspan="2" style="padding-top: 14px; padding-bottom: 10px;">
                                <center>
                                    <asp:Button ID="BtnMail" Style="" Text="Mail" CssClass="btnn" runat="server" OnClick="BtnMail_Click"
                                        OnClientClick="return MailSubmit();" />
                                </center>
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
                <Triggers>
                <asp:AsyncPostBackTrigger ControlID="BtnMail" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>
    </div>
    </form>
</body>

解决方法

那这个呢 ?

string tempabc = "javascript:window.open('ReportViewer.aspx?ReportType=" + rptnew + "&Billno=" + billno + "&Mail=" + "Mail" + "&CCMail=" + CCMail + "&Subject=" + txtSubject.Text + "&MailBody=" + txtMailBody.Text + "','_blank')";

要么

在按钮中添加formtarget =“_ blank”属性

要么

<button  onclick="a()">Click Me</button> 
<script>
function a()
{
    window.open('url','_blank','width=300,height=200');
}
</script>

如果你没有提到尺寸,它将在新标签中打开,否则作为弹出窗口.

window.open('url','_blank') - next tab
window.open('url',height=200') - popup

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐