0
在ASP.net和C#中 - 在我的pageLoad事件中,我单击了一个按钮,该按钮已写入代码以获取SSO链接,然后使用RegisterStartUpScript添加一个window.open以及其中的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());
}
}
任何想法表示赞赏。
您需要为弹出窗口添加一个EventListener。 – Botonomous
感谢关键字@Anon。我尝试添加var popupWindow = window.open(''+ link +'','_ blank','width = 980,height = 600,resizable = yes');如果(popupWindow){popupWindow.onload = function(){window.location.replace(''+ redirectAddress +'')};},但是因为它是跨域的,我不认为我的JS可以得到这个函数当window.onLoad会触发。我正在考虑设置一个超时来解决它。 – David
那么,为了我的需要,我只是确定我不需要听众或任何东西。我刚刚在启动脚本中添加了重定向语言,而不是在C#中。如果需要,我将创建一个添加脚本的设置,如果没有,它将保留在页面上,而不是重定向。我稍后会添加代码。 – David