TabContainer抑制UpdatePanel的beginRequest和endRequest吗

TabContainer suppressing beginRequest and endRequest of UpdatePanel?
2020-11-21
  •  译文(汉语)
  •  原文(英语)

我在TabContainer内部有一些控件,而TabContainer在UpdatePanel内部.我正在尝试使用以下JavaScript恢复TabContainer内部面板的滚动位置:

var yPanel;

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args) {
    yPanel = $get('ScrollPanel').scrollTop;
}
function EndRequestHandler(sender, args) {
    $get('ScrollPanel').scrollTop = yPanel;
}

把这些断点在Chrome中,我看到的BeginRequestHandlerEndRequestHandler在外面TabContainer的(和UpdatePanel内)控制激活回传,我看到被压在里面TabContainer的按钮时,断点触发被触发.但是,TabContainer内部的任何其他控件(例如带有的复选框AutoPostBack="true")的确会触发回发,但不会触发BeginRequestHandlerEndRequestHandler事件.

我还将调试器附加到服务器上,并且能够确认在使用TabContainer外部的控件或TabContainer内部的按钮时,我得到了以下断点序列:

  1. BeginRequestHandler(客户端)
  2. Page_Load(服务器端)
  3. EndRequestHandler(客户端)

但是,当在TabContainer中使用其他控件时,我得到以下断点序列:

  1. Page_Load(服务器端)

TabContainer是否在某个地方自行处理这些事件?为什么不发生呢?

速聊1:
但是,这可以在我刚刚创建的小型演示中使用...
解决过程1

在我创建的一个小型演示中找到此功能后,我便开始计算香草演示和页面之间的区别.

关键区别以及实际上是导致这些事件不触发的区别是ClientIDMode="Static"在TabContainer及其选项卡上的使用.不幸的是,我不知道为什么ClientID静态会导致此问题,但是如果将来有人遇到类似的问题,这就是您要注意的问题.只需将更ClientIDMode改为默认值Inherit,即可AutoID再次执行此操作,并触发事件.

I have some controls inside of a TabContainer and the TabContainer is inside of an UpdatePanel. I'm attempting to restore the scroll position of a panel inside of the TabContainer with the following javascript:

var yPanel;

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args) {
    yPanel = $get('ScrollPanel').scrollTop;
}
function EndRequestHandler(sender, args) {
    $get('ScrollPanel').scrollTop = yPanel;
}

Putting a breakpoint on these in Chrome, I see that the BeginRequestHandler and the EndRequestHandler are triggered when controls outside the TabContainer (and inside the UpdatePanel) activate a postback and I see the breakpoints trigger when buttons inside the TabContainer are pressed. However, any other control inside the TabContainer (for example a checkbox with AutoPostBack="true") does trigger a postback, but the BeginRequestHandler and the EndRequestHandler events are not triggered.

I also attached the debugger to the server and was able to confirm, when using controls outside the TabContainer or buttons inside the TabContainer, I get the following sequence of breakpoints:

  1. BeginRequestHandler (client side)
  2. Page_Load (Server side)
  3. EndRequestHandler (client side)

However, when using other controls inside of the TabContainer, I get the following sequence of breakpoints:

  1. Page_Load (Server side)

Is the TabContainer handling these events on its own somewhere? Why are they not happening?

Talk1:
However, this works in the small demo I just created...
Solutions1

After I found this working in a small demo I created, I started to work out the differences between my vanilla demo and my page.

The key difference and indeed the difference that was causing these events not to fire was the use of ClientIDMode="Static" on the TabContainer and its Tabs. Unfortunately I don't know why the ClientID being static would cause this issue, but if anyone experiences a similar issue in the future, this is what you'll want to look out for. Simply changing the ClientIDMode to the default Inherit or AutoID makes this work again and causes the events to fire.

转载于:https://stackoverflow.com/questions/28333705/tabcontainer-suppressing-beginrequest-and-endrequest-of-updatepanel

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入