是这样的 updatepanel包含该用户控件,但这个用户控件的内容是动态生成的,用triggers找到相应内容的ID时报错 显示无法找到控件ID 但我拿掉triggers时执行正常 ID还是那个ID 没有变 难道跟执行顺序有关么 求解
ID所指的控件是否有runat=server?
加了
@Aaron_Li: 把代码贴出来帮你看看
@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>
@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
@wolfy:刚午休下来 嘿嘿 还有动态生成的内容 里面有BatteryOneID0的
@Aaron_Li: 找不到那是 创建和执行的顺序 有问题了
@wolfy: 嗯 应该是 还是谢谢你啦