简体   繁体   English

防止一个控件的页面生命周期

[英]Preventing page lifecycle for one control

I'm using a file manager-type WebControl that does lots of postbacks. 我正在使用一个文件管理器类型的WebControl来执行大量的回发。 It's placed inside a Page that is relatively complex. 它放在一个相对复杂的Page内。 I would like to prevent the WebControl from causing the whole Page to go through the lifecycle. 我想阻止WebControl导致整个Page经历生命周期。 An UpdatePanel helps a little, but not enough. UpdatePanel可以提供一些帮助,但还不够。

Is there any way to isolate the WebControl from the rest of the Page ? 有什么办法可以将WebControlPage的其余部分隔离开吗? The only way I can think of is sticking the WebControl in a separate Page and creating an iframe in the original Page . 我能想到的唯一方法是将WebControl粘贴在单独的Page然后在原始Page创建一个iframe Unfortunately that also means my WebControl properties/settings are no longer in the original Page . 不幸的是,这也意味着我的WebControl属性/设置不再位于原始Page If I want two instances of the WebControl with different settings, then I have to create a Page for each setting and reference the correct one in my iframes . 如果我想要两个具有不同设置的WebControl实例,那么我必须为每个设置创建一个Page并在我的iframes引用正确的一个。 Not quite as "drag & drop" as I would like. 不像我想要的那样“拖放”。 Any other suggestions? 还有其他建议吗?

Hard to tell, you can't prevent a control from going through lifecycle; 很难说,您不能阻止控件贯穿生命周期。 is there anyway to identify though, that during a certain page postback, you prevent the code from running in each event handler by doing something like: 但是无论如何都要确定,在某个页面回发期间,您通过执行以下操作来阻止代码在每个事件处理程序中运行:

if (_shouldNotRun == true)
   return;

//Event handler code

Essentially, figuring out some way to indicate whether the control should run may be an option. 本质上,找出某种方式指示控件是否应该运行可能是一种选择。 IFrame would work, but yes you have to deal with the issues you mentioned. IFrame可以使用,但是是的,您必须处理您提到的问题。 Can you give more detals to the problem? 您能否进一步解决这个问题?

HTH. HTH。

Not 100% sure what events possible to override that are called on PostBack. 不是100%确定可以覆盖在PostBack上调用的事件。 A good source for the Life Cycle of a page (http://msdn.microsoft.com/en-us/library/ms178472.aspx) 页面生命周期的良好来源(http://msdn.microsoft.com/zh-cn/library/ms178472.aspx)

But it sounds as it would be better to remake your control to create Ajax webservice requests for the functions that are possible to prevent most of the postback's? 但是,听起来好像最好重新制作控件,以便为可能防止大多数回发的功能创建Ajax Web服务请求?

Cheers, Stefan 干杯,斯特凡

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM