ASP.NET如何实现线程中调用JS函数?
在ASP.NET里,同一个页面,有一个js写的function
如:test.aspx内
<script type="text/javascript">
function show(x)
{
alert(x);
}
</script>
test.aspx.cs内
有两个 button,
//button1,这个可以正常运行
protected void Button1_Click(object sender, EventArgs e)
{
Page.RegisterStartupScript("test", "<script>show(" + 3 + ");</script>");
}
// button2,这个不能正常运行,但是不报错,很奇怪
protected void Button2_Click(object sender, EventArgs e)
{
System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(t_t));
t.Start();
}
void t_t()
{
try
{
Page.RegisterStartupScript("test", "<script>show(" + 3 + ");</script>");
}
catch (Exception s)
{
Response.Write(s.ToString());
throw;
}
}
我的目地就是要调前台一个JS的Function几千次,当然Funtiocn里不可能只有Alert,如果直接循环调,太慢了