我的页面内有一个UpdatePanel,绑定了一个计时器,我想在这个定时器函数内调用客户端代码,不成功,请高手帮我看看:
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function Test()
{
alert("111");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="1000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>服务端代码:
protected void Timer1_Tick(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Timer1, this.GetType(), "key", "Test", true);
}
我就是想在这个定时器内每过一秒就调用一次客户端函数Test(),现在试验没什么效果,这是为什么啊?
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function Test()
{
alert("111");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" ontick="Timer1_Tick" Interval="1000">
</asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick">
</asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>服务端代码:
protected void Timer1_Tick(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Timer1, this.GetType(), "key", "Test", true);
}
我就是想在这个定时器内每过一秒就调用一次客户端函数Test(),现在试验没什么效果,这是为什么啊?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货