updatepanel 刷新 gridview太慢的解决方法,当包含dropdownlist控件时

时间:2022-08-25 17:22:27

转载:

忘了从哪里找到的,是一个国外网站.

只要在</form>后面使用以下代码,就可以加速刷新.

 

    < script  language ="javascript"  type ="text/javascript" >

        
function  disposeTree(sender, args) {
            
var  elements  =  args.get_panelsUpdating();
            
for  ( var  i  =  elements.length  -   1 ; i  >=   0 ; i -- ) {
                
var  element  =  elements[i];
                
var  allnodes  =  element.getElementsByTagName( ' * ' ),
                length 
=  allnodes.length;
                
var  nodes  =   new  Array(length)
                
for  ( var  k  =   0 ; k  <  length; k ++ ) {
                    nodes[k] 
=  allnodes[k];
                }
                
for  ( var  j  =   0 , l  =  nodes.length; j  <  l; j ++ ) {
                    
var  node  =  nodes[j];
                    
if  (node.nodeType  ===   1 ) {
                        
if  (node.dispose  &&   typeof  (node.dispose)  ===   " function " ) {
                            node.dispose();
                        }
                        
else   if  (node.control  &&   typeof  (node.control.dispose) ===   " function " ) {
                            node.control.dispose();
                        }

                        
var  behaviors  =  node._behaviors;
                        
if  (behaviors) {
                            behaviors 
=  Array.apply( null , behaviors);
                            
for  ( var  k  =  behaviors.length  -   1 ; k  >=   0 ; k -- ) {
                                behaviors[k].dispose();
                            }
                        }
                    }
                }
                element.innerHTML 
=   "" ;
            }

        }
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(disposeTree);

</ script >