且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在每个页面上登录和注销

更新时间:2023-12-04 16:30:40

答案不是很明显,但这是(我认为):
您可以使用登录控件的按钮的OnClick事件设置会话变量.这是在PageLoad事件后之后触发的,该事件设置了Login/Logout按钮的可见性.这就是为什么它第一次失败"的原因.

要解决此问题,请将按钮可见性代码移动到OnPreRender,然后将其移动到在登录时被显式调用的新方法.

最后要注意的是,具有良好的控制和变量名的代码将更易于阅读...

希望这会有所帮助!
The answer is not obvious, but here it is (I think):
You set the session variables using the Login Control''s Button''s OnClick event. This is fired after the PageLoad event which sets the Login/Logout button visibility. This is why it "fails" the first time.

To fix, either move the button visibility code to OnPreRender, move it to a new method that gets called explicitly at login.

As a final note, the code would be much easier to read with good control and variable names...

Hope this helps!