Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 打开弹出窗口后,如何重定向父页面?_C#_Javascript_Asp.net_Redirect - Fatal编程技术网

C# 打开弹出窗口后,如何重定向父页面?

C# 打开弹出窗口后,如何重定向父页面?,c#,javascript,asp.net,redirect,C#,Javascript,Asp.net,Redirect,在ASP.net和C#-在我的pageLoad事件中,我单击一个按钮,该按钮编写了获取SSO链接的代码,然后使用RegisterStartUpScript添加一个窗口。打开窗口时,其中包含指向SSO的链接 在SSO打开并加载后,我想将带有pageLoad事件的页面重定向到另一个页面 在下面的代码中,autoOpenSSO和redirectUser是在管理UI中加载的设置 问题:当autoOpenSSO为true且我将redirectUser设置为false时,弹出窗口打开时不会出现问题,但当我将

在ASP.net和C#-在我的pageLoad事件中,我单击一个按钮,该按钮编写了获取SSO链接的代码,然后使用RegisterStartUpScript添加一个窗口。打开窗口时,其中包含指向SSO的链接

在SSO打开并加载后,我想将带有pageLoad事件的页面重定向到另一个页面

在下面的代码中,autoOpenSSO和redirectUser是在管理UI中加载的设置

问题:当autoOpenSSO为true且我将redirectUser设置为false时,弹出窗口打开时不会出现问题,但当我将重定向设置为true时,弹出窗口不会打开,页面会重定向回我的重定向地址

我希望弹出窗口打开,页面重定向回我的重定向页面,但感觉好像我错过了什么,没有任何运气搜索

我的代码:

protected void Page_Load(object sender, EventArgs e)
    {        
       if (autoOpenSSO == true)
       {
           ccdetails_Click(this, null);
       }


     if (redirectUser == true)
       {               
        Response.Redirect(redirectAddress);               
       }


    }

    protected void ccdetails_Click(object sender, EventArgs e)
    {
        ClientScriptManager cs = Page.ClientScript;
        try
        {  
            string link = getSSOlink(ah1.InstitutionUserID, cardnumber).Trim();
            string s = "window.open('" + link + "','_blank', 'width=980,height=600,resizable=yes');";
            cs.RegisterStartupScript(this.GetType(), "PopupScript", s, true);

        }

        catch (Exception se)
        {
           LogSystem.LogInfo(se.ToString());

        }
    }

任何想法都非常感谢。

我所要做的就是在我的注册启动脚本中添加另一行js,重定向到我想要的页面。修改后的代码可以在下面找到。我的页面上有一些设置,允许我决定是否要自动打开SSO并在SSO打开后自动重定向用户,这是s=s+t部分的目的

protected void Page_Load(object sender, EventArgs e)
    {         

       if (autoOpenSSO == true)
       {
           ccdetails_Click(this, null);
       }

    }

    protected void ccdetails_Click(object sender, EventArgs e)
    {
        ClientScriptManager cs = Page.ClientScript;
        try
        {                
            string link = getSSOlink(ah1.InstitutionUserID, cardnumber).Trim();
            string s = "var popupWindow = window.open('" + link + "','_blank', 'width=980,height=600,resizable=yes');";
            string t = "window.location.replace('" + redirectAddress + "')";
            if (redirectUser == true)
            {
                s = s + t;
            }
            cs.RegisterStartupScript(this.GetType(), "PopupScript", s, true);

        }

        catch (Exception se)
        {
            LogSystem.LogInfo("Access issue - " + se.ToString());

        }
    }

您需要为弹出窗口添加一个EventListener。感谢关键字@Anon。我尝试添加var popupWindow=window.open(“+link+”,“\u blank”,“width=980,height=600,resizable=yes”);如果(popupWindow){popupWindow.onload=function(){window.location.replace(“+redirectAddress+”)};},但由于它是跨域的,我认为我的JS无法在window.onload启动时获得do the函数。我正在考虑设置一个超时来修复它。嗯,出于我的需要,我刚刚决定我不需要一个听众或任何东西。我只是在启动脚本中添加了重定向语言,而不是在C#中。如果需要,我将创建一个添加脚本的设置,如果不需要,它将保留在页面上,而不会重定向。稍后我将添加代码。