Repeater 的ItemCommand事件不响应-----我遇到的诡异的问题(已解决)

今天碰到一个页面,Repeater的Itemcommand事件死活不响应,网上搜了一搜,问的人还真多,可能解决的很少,估计是各有各的原因。像其他人所说的什么事件没有注册啊,ispostback没有判断啊等等,通通都不属于我存在的问题。我当时很是奇怪,因为我弄了个测试页面,上面只有一个repeater,没有其他任何东西,这个repeater就能响应的好好的。所以问题还是出现在那个页面上。经过反复试验,终于有了一个惊人的发现:
原来,页面上包含一个用户控件head011,内容大致如下
< script  language ="javascript"  type ="textjavascript" >
var domainroot="www.sina.com.cn"// 你的网站域名 
  function Gsitesearch(curobj)
  curobj.q.value
="site:"+domainroot+" "+curobj.qfront.value 
  }
 
</ script >
< form  action ="http://www.google.com/search"  method ="get"  onSubmit ="Gsitesearch(this)" > 注意此处很关键
    
< br >
    
< table  width ="765"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
        
< tr >
            
< td  width ="250" >< img  src ="images/l001.gif"  width ="250"  height ="61" ></ td >
            
< td  width ="510"  valign ="bottom" >< table  width ="0"  border ="0"  align ="right"  cellpadding ="0"  cellspacing ="0" >
                    
< tr >
                        
< td >
                            
&nbsp;   < href ="index.aspx"  class ="ch007" > 首页 </ a >   < href ="lxwm.aspx"  class ="ch007" >
                                联系我们
</ a >   < href ="yqlj.aspx"  class ="ch007" ></ a >
                        
</ td >
                    
</ tr >
                
</ table >
            
</ td >
        
</ tr >
    
</ table >
    
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
        
< tr >
            
< td >< img  src ="images/l002.gif"  width ="768"  height ="29" ></ td >
        
</ tr >
    
</ table >
    
< table  width ="768"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
        
< tr >
            
< td  width ="247"  height ="23"  background ="images/l003.gif" > &nbsp; </ td >
            
< td  width ="307"  background ="images/l003.gif" >< href ="gywm_gsjj.aspx" >< img  src ="images/l019.gif"  width ="62"  height ="23"  border ="0" ></ a >< href ="xw_lb.aspx" >< img  src ="images/l020.gif"  width ="75"  height ="23"  border ="0" ></ a >< href ="tzzgx_llwm.aspx" >< img  src ="images/l021.gif"  width ="86"  height ="23"  border ="0" ></ a >< href ="ywjs.aspx" >< img  src ="images/l022.gif"  width ="60"  height ="23"  border ="0" ></ a ></ td >
            
< td  width ="64"  background ="images/l003.gif" >< select  name ="select"  size ="1"  class ="table001" >
                    
< option  selected > 标题 </ option >
                    
< option > 内容 </ option >
                    
< option > 作者 </ option >
                
</ select ></ td >
            
< p >
                
< td  width ="110"  background ="images/l003.gif" >< input  name ="q"  type ="hidden" >< input  name ="qfront"  type ="text"  class ="table002"  value ="搜索内容"  size ="20" ></ td >
                
< td  width ="40"  background ="images/l003.gif" >< input  type ="submit"  class ="table003"  value ="go" ></ td >
            
</ p >
        
</ tr >
    
</ table >
</ form >

而出问题的页面大致如下:
<% @ Register TagPrefix="uc1" TagName="down02" Src="Controls/down02.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="left01" Src="Controls/left01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="head01" Src="Controls/head01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="meta01" Src="Controls/meta01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="title01" Src="Controls/title01.ascx"  %>
<% @ Page CodeBehind="xzym.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Exhibition.web.xzym"  %>
< HTML >
    
< HEAD >
        
< uc1:meta01  id ="meta011"  runat ="server" ></ uc1:meta01 >
        
< uc1:title01  id ="title011"  runat ="server" ></ uc1:title01 >
        
< link  href ="ch.css"  rel ="stylesheet"  type ="text/css" >
    
</ HEAD >
    
< body  topmargin ="0" >
    
< form  id ="Form1"  runat ="server"  method ="post" > 注意此处很关键
        
< uc1:head01  id ="head011"  runat ="server" ></ uc1:head01 >注意 此处很关键
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="images/l002.png"  width ="767"  height ="138" ></ td >
            
</ tr >
        
</ table >
        
< table  width ="767"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td  width ="190"  valign ="top"  bgcolor ="#f3f3f3" >
                    
< uc1:left01  id ="left011"  runat ="server" ></ uc1:left01 >
                
</ td >
                
< td  width ="580"  valign ="top" >< table  width ="100%"  height ="33"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  width ="580"  height ="33"  background ="images/l034.gif" > &nbsp; < img  src ="images/l017.gif"  width ="10"  height ="11" >< href ="index.aspx"  class ="ch003" > 首页 &gt; </ a >< href ="#"  class ="ch008" >
                                    下载页面
</ a ></ td >
                        
</ tr >
                    
</ table >
                    
< br >
                    
< table  width ="90%"  height ="26"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  width ="84%"  background ="../images/ch_l_063.gif"  class ="ch001" > &nbsp; < span  class ="ch003" >< strong > 资料下载 
                                        :
</ strong ></ span ></ td >
                            
< td  width ="16%"  background ="../images/ch_l_063.gif"  class ="ch004" > 点击下载 </ td >
                        
</ tr >
                    
</ table >
                    
< asp:Repeater  id ="Repeater1"  runat ="server" >
                        
< HeaderTemplate >
                            
< table  width ="90%"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  align ="center"  valign ="top"  background ="../images/ch_l_066.gif" >
                        
</ HeaderTemplate >
                        
< ItemTemplate >
                            
< table  width ="511"  height ="65"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  width ="429"  height ="65"  align ="left"  class ="ch007" > <% # DataBinder.Eval(Container, "DataItem.FileDownName") %> ( <% # DataBinder.Eval(Container, "DataItem.FileSize") %> ) </ td >
                                    
< td  width ="82"  align ="center" >< asp:ImageButton  id ="lbtn_download2"  runat ="server"  ImageUrl  ="../images/ch_l_067.gif"  Width ="35"  Height  ="28"  BorderWidth  ="0"  CommandName  ="download"  CommandArgument  ='<%#  DataBinder.Eval(Container, "DataItem.FileID")% > '> </ asp:ImageButton >< span  class ="ch005" >< br  />
                    Download
</ span ></ td >
                                
</ tr >
                            
</ table >
                        
</ ItemTemplate >
                        
< AlternatingItemTemplate >
                            
< table  width ="511"  height ="65"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  width ="429"  height ="65"  align ="left"  class ="ch007" > <% # DataBinder.Eval(Container, "DataItem.FileDownName") %> ( <% # DataBinder.Eval(Container, "DataItem.FileSize") %> ) </ td >
                                    
< td  width ="82"  align ="center" >< asp:ImageButton  id ="ibtn_download1"  runat ="server"  ImageUrl  ="../images/ch_l_068.gif"  Width  ="35"  Height  ="28"  BorderWidth  ="0"  CommandName  ="download"  CommandArgument  ='<%#  DataBinder.Eval(Container, "DataItem.FileID")% > '> </ asp:ImageButton >< span  class ="ch005" >< br  />
                    Download
</ span ></ td >
                                
</ tr >
                            
</ table >
                        
</ AlternatingItemTemplate >
                        
< FooterTemplate >
                
</ td >
            
</ tr >
        
</ table >
        
</ FooterTemplate >   </ asp:Repeater >
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="../images/dna01.gif"  width ="500"  height ="9" ></ td >
            
</ tr >
        
</ table >
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="../images/ch_l_056.gif"  width ="550"  height ="10" ></ td >
            
</ tr >
        
</ table >
        
</ td >   </ tr >   </ table >
        
< uc1:down02  id ="down021"  runat ="server" ></ uc1:down02 >
        
</ form >
    
</ body >
</ HTML >

这样的两个分别都要提交的FROM的结构,存在问题,导致了Itemcommand的事件不能响应。我虽然找到了原因,但并不知道原理是什么,还请高手赐教,不胜感激。
所以针对我的这个页面的问题来说,就很好解决了,把页面改成如下的结构,问题就迎刃而解了:
<% @ Register TagPrefix="uc1" TagName="down02" Src="Controls/down02.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="left01" Src="Controls/left01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="head01" Src="Controls/head01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="meta01" Src="Controls/meta01.ascx"  %>
<% @ Register TagPrefix="uc1" TagName="title01" Src="Controls/title01.ascx"  %>
<% @ Page CodeBehind="xzym.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="Exhibition.web.xzym"  %>
< HTML >
    
< HEAD >
        
< uc1:meta01  id ="meta011"  runat ="server" ></ uc1:meta01 >
        
< uc1:title01  id ="title011"  runat ="server" ></ uc1:title01 >
        
< link  href ="ch.css"  rel ="stylesheet"  type ="text/css" >
    
</ HEAD >
    
< body  topmargin ="0" >
         
< uc1:head01  id ="head011"  runat ="server" ></ uc1:head01 > 注意此处很关键---------将这句话提到FORM的外面去
    
< form  id ="Form1"  runat ="server"  method ="post" >     注意此处很关键    
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="images/l002.png"  width ="767"  height ="138" ></ td >
            
</ tr >
        
</ table >
        
< table  width ="767"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td  width ="190"  valign ="top"  bgcolor ="#f3f3f3" >
                    
< uc1:left01  id ="left011"  runat ="server" ></ uc1:left01 >
                
</ td >
                
< td  width ="580"  valign ="top" >< table  width ="100%"  height ="33"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  width ="580"  height ="33"  background ="images/l034.gif" > &nbsp; < img  src ="images/l017.gif"  width ="10"  height ="11" >< href ="index.aspx"  class ="ch003" > 首页 &gt; </ a >< href ="#"  class ="ch008" >
                                    下载页面
</ a ></ td >
                        
</ tr >
                    
</ table >
                    
< br >
                    
< table  width ="90%"  height ="26"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                        
< tr >
                            
< td  width ="84%"  background ="../images/ch_l_063.gif"  class ="ch001" > &nbsp; < span  class ="ch003" >< strong > 资料下载 
                                        :
</ strong ></ span ></ td >
                            
< td  width ="16%"  background ="../images/ch_l_063.gif"  class ="ch004" > 点击下载 </ td >
                        
</ tr >
                    
</ table >
                    
< asp:Repeater  id ="Repeater1"  runat ="server" >
                        
< HeaderTemplate >
                            
< table  width ="90%"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  align ="center"  valign ="top"  background ="../images/ch_l_066.gif" >
                        
</ HeaderTemplate >
                        
< ItemTemplate >
                            
< table  width ="511"  height ="65"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  width ="429"  height ="65"  align ="left"  class ="ch007" > <% # DataBinder.Eval(Container, "DataItem.FileDownName") %> ( <% # DataBinder.Eval(Container, "DataItem.FileSize") %> ) </ td >
                                    
< td  width ="82"  align ="center" >< asp:ImageButton  id ="lbtn_download2"  runat ="server"  ImageUrl  ="../images/ch_l_067.gif"  Width ="35"  Height  ="28"  BorderWidth  ="0"  CommandName  ="download"  CommandArgument  ='<%#  DataBinder.Eval(Container, "DataItem.FileID")% > '> </ asp:ImageButton >< span  class ="ch005" >< br  />
                    Download
</ span ></ td >
                                
</ tr >
                            
</ table >
                        
</ ItemTemplate >
                        
< AlternatingItemTemplate >
                            
< table  width ="511"  height ="65"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                                
< tr >
                                    
< td  width ="429"  height ="65"  align ="left"  class ="ch007" > <% # DataBinder.Eval(Container, "DataItem.FileDownName") %> ( <% # DataBinder.Eval(Container, "DataItem.FileSize") %> ) </ td >
                                    
< td  width ="82"  align ="center" >< asp:ImageButton  id ="ibtn_download1"  runat ="server"  ImageUrl  ="../images/ch_l_068.gif"  Width  ="35"  Height  ="28"  BorderWidth  ="0"  CommandName  ="download"  CommandArgument  ='<%#  DataBinder.Eval(Container, "DataItem.FileID")% > '> </ asp:ImageButton >< span  class ="ch005" >< br  />
                    Download
</ span ></ td >
                                
</ tr >
                            
</ table >
                        
</ AlternatingItemTemplate >
                        
< FooterTemplate >
                
</ td >
            
</ tr >
        
</ table >
        
</ FooterTemplate >   </ asp:Repeater >
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="../images/dna01.gif"  width ="500"  height ="9" ></ td >
            
</ tr >
        
</ table >
        
< table  width ="0"  border ="0"  align ="center"  cellpadding ="0"  cellspacing ="0" >
            
< tr >
                
< td >< img  src ="../images/ch_l_056.gif"  width ="550"  height ="10" ></ td >
            
</ tr >
        
</ table >
        
</ td >   </ tr >   </ table >
        
< uc1:down02  id ="down021"  runat ="server" ></ uc1:down02 >
        
</ form >
    
</ body >
</ HTML >

我的问题是解决了。可我最终还是不知道,为什么将那个包含一个form的<uc1>提到页面Form标签的外面去,就能解决这个问题。换句话说,为什么<uc1>放到页面的Form标签的里面,就能造成itemcommand事件的不响应呢??盼望高手的解答。。。。。。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值