也许它的东西,小我没有看到...... 我有一个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