asp.net调用JS方法的问题
我在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中就点一次按钮执行一次
请问谁遇到过类似问题?谢谢
相关推荐
.net调用js脚本
net调用js脚本
JS调用C#后台方法
js调用后台方法 js JS调用后台 JS后台方法 用到了[WebService]特性
JS的DLL封装及调用
将JS脚本封装到DLL中,然后在前台调用。这样做的好处,即可以提高代码的可重用性,又可以提高代码的安全性,防止他人恶意修改。
【ASP.NET编程知识】ASP.NET中常用输出JS脚本的类实例.docx
【ASP.NET编程知识】ASP.NET中常用输出JS脚本的类实例.docx
aspnet-formsauthentication-js:ASP.NET FormsAuthentication的最小JavaScript实现
aspnet-formsauthentication-js ASP.NET FormsAuthentication Encrypt()和Decrypt()方法的最小JavaScript实现。


