加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 22:13:28 所属栏目:百科 来源:网络整理
导读:我想在按钮点击上打开新标签,点击的按钮存在于iframe上. 我用这个代码 – string tempabc = "javascript:window.open('ReportViewer.aspx?ReportType=" + rptnew + "Billno=" + billno + "Mail=" + "Mail" + "CCMail=" + CCMail + "Subject=" + txtSubject.T
我想在按钮点击上打开新标签,点击的按钮存在于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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读