重定向到ASP.NET新标签 [英] Redirect to new tab in ASP.NET

查看:163
本文介绍了重定向到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");
        }
    }

我尝试从这个帖子在新标签中打开一个URL适用答案,以我的情况,但只是获得左上角如文本window.open ......

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

_blank 添加链接 - 也于事无补。

Add _blank to link - also doesn't help.

推荐答案

您是基于触发点击动态重定向。我认为,对于这种情况,你实际上可以改变它来设置您的HREF前点击,因为你知道在页面加载数据,前提是你的样品code是完整的。

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.

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

请你的目标设定的方式是从你的链接按钮删除onclick事件。现在应该在新窗口中打开动态的目标。

Keep your target set the way it is and remove the onclick event from your link button. It should now open your "dynamic" target in a new window.

这篇关于重定向到ASP.NET新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆