我有一个asp.net网站,它需要登录并保存到会话中的一个类。当会话到期时(或当我清除它时),我需要用户重新登录,但最好不要返回主登录页面(因为用户将丢失到那时为止键入的所有内容)。
在主页OnInit上,我检查会话是否为空,如果是,它们将被注销。我在我的母版页上创建了一个jquery模式对话框,它接受登录信息并在有效登录的情况下重新创建会话。
这是可行的,但是,在用户登录并关闭对话框之后,该对话框将再次打开(此时,会话不为空)。
我尝试在登录过程中设置一个不同的会话值,这样它就不会打开模式对话框,但是它看不到它并打开它(并且看到登录会话是空的,尽管它不是空的。
退出对话框后,一切都很好。
有人能告诉我我哪里出错了吗?或者如何防止对话框打开两次?
母版页:
<script type="text/javascript">
function showloginpopup() {
$("#popuplogin").dialog({
resizable: false,
width: 320,
height: 310,
modal: true,
// dialogClass: "no-close", // adding this would remove the x button
appendTo: "form",
buttons: {
}
});
};
</script>
<asp:UpdatePanel ID="upLogin" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div id="popuplogin" style="display: none;" class="ticker" title="Login">
<asp:Panel ID="pnlWorkArea" runat="server" CssClass="login_workarea_panel" DefaultButton="btnLogin">
<%-- textboxes and btnLogin for logging in --%>
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>btnLogin读取文本框并使用用户信息填充我的会话。
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (Classes.LoggedInUser.Current.loggedInUser == null) // This is returning null on 2nd time even though after first time it is set
{
ScriptManager.RegisterStartupScript(this, GetType(), "Show Login Popup", "showloginpopup();", true);
loadData(); // Populate some buttons based on permissions from login
}
}谢谢!
https://stackoverflow.com/questions/38330552
复制相似问题