简体   繁体   中英

TabContainer suppressing beginRequest and endRequest of UpdatePanel?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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