如何在asp.net页面中仅触发page_load事件 [英] How to fire only page_load event in a asp.net page

查看:114
本文介绍了如何在asp.net页面中仅触发page_load事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在.aspx页面中我有一个Page_load事件的条件,所以在每次回发时

检查这个条件,即session.isnewsession ()。如果结果为false,则页面代码的其余部分执行,但如果结果为true,则页面停止执行任何进一步的事件,只是将其自身呈现为原样。

喜欢,如果ddl_city导致回发,将检查page_load中的条件。如果为false,则正常执行将继续。如果结果为true,则该页面中不会触发进一步的控制事件,甚至ddl_city_SelectedIndexChanged也不会触发。

我该怎么做?

到目前为止,我已经明白控件的生命周期不能被打破。

请建议。

解决方案

您可以随时添加

 HttpContext.Current.ApplicationInstance.CompleteRequest( ); 



它将优雅地完成请求。


我在想Exit Sub,不知道上面的解决方案1

Hello everyone,
In a .aspx page I have a condition in Page_load event, so that on each postback
this condition is checked,i.e,session.isnewsession(). If the result is false the rest of the page code executes but if the result is true then page stops execution any further event and just renders itself as it was.
Like, If ddl_city has caused the postback, the condition in page_load will be checked. If false the normal execution will carry on. If the result is true then no further control event in that page will fire,not even ddl_city_SelectedIndexChanged.
How can I do it?
So far I''ve understood that a control''s lifecycle can''t be broken.
Please suggest.

解决方案

You can always add the

HttpContext.Current.ApplicationInstance.CompleteRequest();


it will gracefully complete the request.


I was thinking Exit Sub, didn''t know about the above solution 1


这篇关于如何在asp.net页面中仅触发page_load事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆