开发者

Sign out button reloads all user controls

I have an aspx page with several user controls (ascx) as well as an asp:button for signing out.

The click event of the button clears the session and does a response.redirect to the login page.

However, before the click event is called, since the page posts back, all of the Page_Load events run for all of the controls.

What is the best way to have the click event code 开发者_如何学运维run without unnecessary reloading of all user controls?


The easiest way would be to add:

if(!IsPostBack)

around your control initialization in Page_Load.


Make your logout button a link to a logout page that performs the session clear on page_load rather than it being a postback. That way the underlying page will never have to re-load.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜