我在学习Asp.Net之后,写了一个母版页后,我无法让它在客户端上运行(实际看到动画)。线程等待操作是在发布网页之前在服务器上完成的,因此动画不是动态的。它只显示页面的最终状态。Asp .Net客户端动态文本
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body bgcolor="red">
<center>
<h2>Hello w3schools!</h2>
<h4 id="aa">qq</h4>
<h3>
<p><%
for (int i = 0; i < 30; i++)
{
System.Threading.Thread.Sleep(25);
int txtLeft = 300 + (int)(100*Math.Sin(i));
int txtTop = 300+(int)(100*Math.Cos(i));
string theText = "Hello there!";
Response.Write("<div style=\"position:absolute; left: "+ txtLeft + "px; top:" + txtTop + "px; \">" + theText +"</div>");
}
%></p>
</h3>
</center>
</body>
</html>
我试图
RUNAT = “客户端”(附近的 “P” 字母是在括号中)
但它失败:
的Runat必须有价值的服务器。
使用JavaScript,并使其在客户端上工作,并使用服务器只是为了提供页面。如果您真的想生成HTML服务器端,请使用asp.net文字控件,而不是response.write。 – frenchie
你的意思是,我需要在aspx文件而不是主文件中编写实际代码? –
我的意思是使用JavaScript和jQuery;把你的for循环中的代码放在一个javascript函数中,并使用jQuery在document.ready上运行 – frenchie