我在更新面板中有一个计时器控件,计时器应该执行一些 javascript。
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="ImagePanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" OnTick="SlideImages" Interval="4000"></asp:Timer>
<div id="slideshow" runat="server">
<div runat="server" id="currentImageDiv" class="current">
<img id="currentImage" src="" runat="server" class="slideImage current" />
<asp:Label runat="server" id="currentImageCaption" CssClass="caption"></asp:Label>
</div>
<div runat="server" id="nextImageDiv" class="next">
<img id="nextImage" src="" runat="server" class="slideImage next" />
<asp:Label runat="server" id="nextImageCaption" CssClass="caption"></asp:Label>
</div>
</div>
<asp:HiddenField runat="server" ID="slideIndexField" Value="1"/>
</ContentTemplate>
</asp:UpdatePanel>
后面的代码:
protected void SlideImages(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(
Timer1,
Timer1.GetType(),
"SlideImages",
@"<script src='Scripts/jquery-1.10.1.min.js' type='text/javascript'></script>
<script type='text/javascript'>
alert('script executed');
</script>",
true);
}
但它似乎不起作用,我必须改变什么?