使用 TabPanel.OnClientClick 实现 TabContainer 按需加载

使用 TabPanel.OnClientClick 实现 TabContainer 实现按需加载,代码如下:

注意:OnClientClick 指定的方法是不能带()的,所以不能指定参数,否则你将得到两个脚本错误:
                Sys.InvalidOperationException: Handler must be a function.
                Sys.InvalidOperationException: Handler was not added through the Sys.UI.DomEvent.addHandler method.
此错误参考:Event handler Javascript error: Sys.InvalidOperationException: Handler must be a function (CalendarPopupExtender)

 

<% @ Page Language = " C# "   %>

<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< script  runat ="server" >

</ script >

< html  xmlns ="http://www.w3.org/1999/xhtml" >
< head  runat ="server" >
    
< title ></ title >

    
< script  type ="text/javascript" >
        
function  LoadTabBaidu() {
            LoadTab(
' frmBaidu ' ' http://www.baidu.com/s?wd=tabcontainer&cl=3&ie=utf-8 '   +  Date());
        }
        
function  LoadTabYahoo() {
            LoadTab(
' frmYahoo ' ' http://one.cn.yahoo.com/s?p=tabcontainer&pid=hp&v=web '   +  Date());
        }
        
function  LoadTabLive() {
            LoadTab(
' frmLive ' ' http://search.live.com/results.aspx?q=tabcontainer&src=IE-SearchBox&Form=IE8SRC&stamp= '   +  Date());
        }
        
function  LoadTab(frmId, frmSrc) {
            
var  frm  =  document.getElementById(frmId);
            
if  (frm.src  ==   "" ) frm.src  =  frmSrc;
        }
    
</ script >

</ head >
< body >
    
< form  id ="form1"  runat ="server" >
    
< div >
        
< asp:ScriptManager  ID ="ScriptManager1"  runat ="server" >
        
</ asp:ScriptManager >
        
< h1 > 使用 TabPanel.OnClientClick 实现 TabContainer 实现按需加载 </ h1 >
        
< ajaxtoolkits:TabContainer  ID ="TabContainer1"  runat ="server"  ActiveTabIndex ="0" >
            
< ajaxtoolkits:TabPanel  ID ="TabPanel1"  runat ="server"  HeaderText ="google" >
                
< ContentTemplate >
                    
< iframe  id ="frmHome"  src ="http://www.google.cn/search?hl=zh-CN&q=tabcontainer&lr="  width ="100%"  height ="500" >
                    
</ iframe >
                
</ ContentTemplate >
            
</ ajaxtoolkits:TabPanel >
            
< ajaxtoolkits:TabPanel  ID ="TabPanel2"  runat ="server"  HeaderText ="baidu"  OnClientClick ="LoadTabBaidu" >
                
<% -- OnClientClick 指定的方法是不能带()的,所以不能指定参数,否则你将得到两个脚本错误:
                Sys.InvalidOperationException: Handler must be a 
function .
                Sys.InvalidOperationException: Handler was 
not  added through the Sys.UI.DomEvent.addHandler method.
                
-- %>
                
< ContentTemplate >
                    
< iframe  id ="frmBaidu"  src =""  width ="100%"  height ="500" ></ iframe >
                
</ ContentTemplate >
            
</ ajaxtoolkits:TabPanel >
            
< ajaxtoolkits:TabPanel  ID ="TabPanel4"  runat ="server"  HeaderText ="Yahoo"  OnClientClick ="LoadTabYahoo" >
                
< ContentTemplate >
                    
< iframe  id ="frmYahoo"  src =""  width ="100%"  height ="500" ></ iframe >
                
</ ContentTemplate >
            
</ ajaxtoolkits:TabPanel >
            
< ajaxtoolkits:TabPanel  ID ="TabPanel3"  runat ="server"  HeaderText ="Live"  OnClientClick ="LoadTabLive" >
                
< ContentTemplate >
                    
< iframe  id ="frmLive"  src =""  width ="100%"  height ="500" ></ iframe >
                
</ ContentTemplate >
            
</ ajaxtoolkits:TabPanel >
        
</ ajaxtoolkits:TabContainer >        
        
    
</ div >
    
</ form >
</ body >
</ html >

 

http://topic.csdn.net/u/20090220/09/8cb42889-c5c9-410e-8d92-c81261b68f88.html?seed=1808103980 

你可能感兴趣的:(使用 TabPanel.OnClientClick 实现 TabContainer 按需加载)