Open a new tab when you click?

I want to open a new tab when a button is clicked, the button that is pressed exists in the 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 he should not show the 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 the same Iframe.

What can I do.

On my .aspx page, I can use those 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>
+4
source share
3 answers

How about this?

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

Or

Add formtarget="_blank"attribute to your button

or

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

If you have not checked size, it will open in a new tabdifferent way popup.

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

Try replacing the current line tempabcwith the following:

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

'_newtab', .

, .

0

You can do something like this also

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

EDIT

Then try the following:

<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();" />

Here you can put several functions.

0
source

Source: https://habr.com/ru/post/1584164/


All Articles