62,243
社区成员




我在asp.net多次调用js方法(不用button click方式),场景是后台数据更新后激活前台刷新页面
ClientScript.RegisterStartupScript只执行一次(key是变量)
js方法:
function test(tt)
{
alert('test'+tt);
}
cs
private static void Data_Monitor()
{
using (SqlConnection connection = new SqlConnection(_connStr))
{
string mntSql = "select ID,BH,MONITOR_DT,MONITOR_VALUE From [dbo].[MONITOR_REALTIME]";
using (SqlCommand command = new SqlCommand(mntSql, connection))
{
command.CommandType = CommandType.Text;
connection.Open();
SqlDependency dependency = new SqlDependency(command);
dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);
command.ExecuteNonQuery();
currentPage.ClientScript.RegisterStartupScript( currentPage.GetType(),"js"+jsCount.ToString(), "<script>test(111);</script>");
jsCount++;
}
}
}
currentPage.ClientScript.RegisterStartupScript( currentPage.GetType(),"js"+jsCount.ToString(), "<script>test(111);</script>"); 只执行一次
如果在button_click中就点一次按钮执行一次
请问谁遇到过类似问题?谢谢