首页 新闻 会员 周边 捐助

用户控件中使用updatepanel报错 显示无法找到控件ID

0
悬赏园豆:20 [已关闭问题] 关闭于 2014-02-25 17:39

是这样的 updatepanel包含该用户控件,但这个用户控件的内容是动态生成的,用triggers找到相应内容的ID时报错 显示无法找到控件ID 但我拿掉triggers时执行正常 ID还是那个ID 没有变 难道跟执行顺序有关么  求解

Aaron_Li的主页 Aaron_Li | 初学一级 | 园豆:131
提问于:2014-02-19 09:59
< >
分享
所有回答(1)
0

ID所指的控件是否有runat=server?

wolfy | 园豆:2636 (老鸟四级) | 2014-02-19 11:37

加了

支持(0) 反对(0) Aaron_Li | 园豆:131 (初学一级) | 2014-02-19 11:38

@Aaron_Li: 把代码贴出来帮你看看

支持(0) 反对(0) wolfy | 园豆:2636 (老鸟四级) | 2014-02-19 11:50

@wolfy: 

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LeftControlOne.ascx.cs" Inherits="CameronSino_CN_QT.Web.Control.LeftControlOne" %> <link href="../CSS/leftcontrol.css" rel="stylesheet" type="text/css" /> <link href="../CSS/jquery-tool.css" rel="stylesheet" type="text/css" />

<%--<script src="../js/jquery-1.8.2.min.js" type="text/javascript"></script>--%> <script src="../js/jquery.tools.min.js" type="text/javascript"></script> <script src="../js/main.js" type="text/javascript"></script> <script src="../js/Control/HeadControl.js" type="text/javascript"></script> <form runat = "server" id="form1"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Block"> <ContentTemplate>  <div id="content">   <ul id="expmenu-freebie" style=" margin:0px; padding:0px;">    <li>     <!-- Start Freebie -->     <ul class="expmenu" style=" padding:0px; margin:0px;">      <li>       <div class="header" id="header1">        <span class="label" style="background-image: url(../images/pc.png);"><span id="span0">电池系列</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulbattery" style=" display: none;">       </ul>      </li>      <li>       <div class="header">        <span class="label" style="background-image:url(../images/pc.png);"><span id="span1">充电器</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulcharger" style=" display:none;">       </ul>      </li>      <li>       <div class="header">        <span class="label" style="background-image:url(../images/pc.png);"><span id="span2">移动电源</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulpower" style="display:none">       </ul>      </li>      <li>       <div class="header">        <span class="label" style="background-image: url(../images/pc.png);"><span id="span3">配件系列</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulparts" style="display:none">       </ul>      </li>                     <li>       <div class="header">        <span class="label" style="background-image: url(../images/pc.png);"><span id="span4">镍氢电池</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulnimhbattery" style="display:none">       </ul>      </li>                     <li>       <div class="header">        <span class="label" style="background-image: url(../images/pc.png);"><span id="span5">保护类</span></span>        <span class="arrow down"></span>       </div>       <ul class="menu" id="menuulprotect" style="display:none">       </ul>      </li>     </ul>     <!-- End Freebie -->    </li>   </ul>  </div>     </ContentTemplate>    <Triggers>  <asp:AsyncPostBackTrigger  ControlID="BatteryOneID0" EventName="Click"/>   </Triggers> </asp:UpdatePanel> </form>

支持(0) 反对(0) Aaron_Li | 园豆:131 (初学一级) | 2014-02-19 11:52

@Aaron_Li: 

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">
<ContentTemplate>
<% =DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
<% =DateTime.Now.ToString()%>
<asp:Button ID="Button2" runat="server" Text="Button" />

你的:

<Triggers>  <asp:AsyncPostBackTrigger  ControlID="BatteryOneID0" EventName="Click"/>   </Triggers> </asp:UpdatePanel>

我用ctrl+f只找到一个BatteryOneID0

支持(0) 反对(0) wolfy | 园豆:2636 (老鸟四级) | 2014-02-19 13:11

@wolfy:刚午休下来 嘿嘿  还有动态生成的内容 里面有BatteryOneID0的

支持(0) 反对(0) Aaron_Li | 园豆:131 (初学一级) | 2014-02-19 14:07

@Aaron_Li: 找不到那是 创建和执行的顺序 有问题了

支持(0) 反对(0) wolfy | 园豆:2636 (老鸟四级) | 2014-02-19 14:41

@wolfy: 嗯  应该是 还是谢谢你啦

支持(0) 反对(0) Aaron_Li | 园豆:131 (初学一级) | 2014-02-19 14:51
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册