简体   繁体   English

重定向到ASP.NET中的新选项卡

[英]Redirect to new tab in ASP.NET

 <asp:LinkButton ID="lnkBtnPrint" runat="server" OnClick="lnkBtnPrint_OnClick" Target="_blank">
                    </asp:LinkButton>

I have Button. 我有巴顿。 I need to open new tab with content on click. 我需要打开带有内容的新标签页。

 protected void lnkBtnPrint_OnClick(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(hdnSubmissionID.Value))
        {
            SessionHelper.Set(SessionKey.SubmissionId, hdnSubmissionID.Value);
            Response.Redirect(PublisherConfigurationManager.Navigation + "Printable_Submission_Document.aspx");
        }
    }

I try to apply answer from this post Opening a URL in a new tab to my case, but just get text in top-left corner like 'window.open...'. 我试图从这篇文章中应用答案我的案例中在新标签页中打开URL ,但是只是在左上角输入文本,例如“ window.open ...”。

Add _blank to link - also doesn't help. _blank添加到链接-也无济于事。

You are dynamically redirecting based on a triggered click. 您正在基于触发的点击进行动态重定向。 I think for this scenario, you could actually change it to set your HRef BEFORE the click, since you know your data on page load, provided that your sample code is complete. 我认为对于这种情况,您可以在单击之前更改它以设置HRef,因为只要您的示例代码完整,就可以知道页面加载时的数据。

public void Page_Load()
{
    if (!string.IsNullOrEmpty(hdnSubmissionID.Value))
    {
        SessionHelper.Set(SessionKey.SubmissionId, hdnSubmissionID.Value);
        lnkBtnPrint.HRef = PublisherConfigurationManager.Navigation + "Printable_Submission_Document.aspx");
    }
}

Keep your target set the way it is and remove the onclick event from your link button. 保持目标设置不变,并从链接按钮中删除onclick事件。 It should now open your "dynamic" target in a new window. 现在,它应该在新窗口中打开“动态”目标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM