[英]After opening popup, How do I redirect parent page?
在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());
}
}
任何想法表示贊賞。
我要做的就是在注冊啟動腳本中添加另一行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());
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.