也許它的東西,小我沒有看到...... 我有一個UserControls_LoginPopUp與屬性之一爲:爲什麼空(登錄彈出)
public string urlForRedirecting {get; set;}
這個用戶控件包含modalpopupextender和方法登錄:
public void Login_Click(object sender, EventArgs e)
{
string user = txtUser.Text;
string passwordMD5 = UtilsStatic.GetMD5Hash(txtPassword.Text);
int id = checkUserAtLogin(user, passwordMD5);
if (id != -1)
{
//MySession.Current.userId = id;
lblStatus.Text = "Autentificare reusita!";
loginPopUp.Hide();
//The user will be redirected
Response.Redirect(this.urlForRedirecting);
this.urlForRedirecting = "";
}
else
{
MySession.Current.userId = -1;
lblStatus.Text = "Autentificare esuata!";
loginPopUp.Show();
}
}
現在,從另一個頁面,用戶點擊一個鏈接,一種方法,其中顯示的模式擴展,所以他可以登錄解僱。請注意,我填補了urlForRedirecting屬性:
public void redirectToWishList(object sender, EventArgs e)
{
if (UtilsStatic.getUserLoggedInId() == -1)
{
ASP.usercontrols_loginpopup_ascx loginUserControl = (ASP.usercontrols_loginpopup_ascx)UtilsStatic.FindControlRecursive(Page, "loginPopUp");
ModalPopupExtender modal = (ModalPopupExtender)loginUserControl.FindControl("loginPopUp");
modal.Show();
//put the link to which the redirect will be done if the user will succesfully login in
loginUserControl.urlForRedirecting = getWishListLink();
}
else
Response.Redirect(getWishListLink());
}
的問題是,在成功地將userr登錄後,該URL爲null(但我已經完成了它已經!!!)
Response.Redirect(this.urlForRedirecting);
你明白爲什麼了嗎?
嗨Fermin。我已經移動了代碼,但也存在同樣的問題。然而,urlForRedirecting是loginUserControl的一個屬性,所以它不依賴於.show。無論如何,謝謝你的建議。 – 2010-01-21 18:47:05
嘗試使urlForRedirecting靜態,因爲當您回發時該值將會丟失。 – Fermin 2010-01-21 19:42:39
您的評論是有幫助的。儘管它沒有回答我的問題,但它給了我一個在這種情況下使用靜態類的理念。謝謝。 – 2010-01-21 20:10:21