Open new tab on button click?

时间:2015-04-23 05:46:37

标签: c# asp.net crystal-reports-2008

I want to open new tab on button click, button that clicked is exist on a Iframe.

I use this code--

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);

but it should't show any result.

then I can use this code-

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

It will open the next page on same Iframe.

what I can do.

In my .aspx page I can use that tags.

<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>

3 个答案:

答案 0 :(得分:1)

这个怎么样?

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>

如果您没有提及size它将在new tab中打开,否则将在popup中打开。

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

答案 1 :(得分:0)

尝试用以下内容替换当前的 java -jar C:\Users\Shivam\Downloads\spoon-runner-1.1.1-jar-with- dependencies.jar --apk D:\Signedapks\external.apk --test-apk C:\Users\Shivam\AndroidStudioProjects\TestingTool\app\build\outputs\apk\app- debug-androidTest-unaligned.apk --sdk E:\sdk 字符串:

tempabc

添加了string tempabc = "javascript:window.open('ReportViewer.aspx?ReportType=" + rptnew + "&Billno=" + billno + "&Mail=" + "Mail" + "&CCMail=" + CCMail + "&Subject=" + txtSubject.Text + "&MailBody=" + txtMailBody.Text + "','_newtab')"; 属性以在新标签中将其打开。

希望它有所帮助。

答案 2 :(得分:0)

你也可以这样做

<asp:Button ID="Button1" runat="server" Text="Button"
    onclick="Button1_Click" OnClientClick="document.forms[0].target = '_blank';" />

修改

然后试试这个:

<script type = "text/javascript">
 function SetTarget() {
     document.forms[0].target = "_blank";
 }
</script>

<asp:Button ID="Button1" runat="server" Text="Button"
    onclick="Button1_Click" OnClientClick = "SetTarget();" />

在这里你可以放置多个功能。