我在學習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