คุณสมบัติบัฟเฟอร์ ASP
❮ การอ้างอิงออบเจ็กต์การตอบสนองที่สมบูรณ์
คุณสมบัติบัฟเฟอร์ระบุว่าจะบัฟเฟอร์เอาต์พุตหรือไม่ เมื่อเอาต์พุตถูกบัฟเฟอร์ เซิร์ฟเวอร์จะระงับการตอบสนองต่อเบราว์เซอร์จนกว่าสคริปต์เซิร์ฟเวอร์ทั้งหมดจะได้รับการประมวลผล หรือจนกว่าสคริปต์จะเรียกใช้เมธอด Flush หรือ End
หมายเหตุ:หากตั้งค่าคุณสมบัตินี้ ควรอยู่ก่อนแท็ก <html> ในไฟล์ .asp
ไวยากรณ์
response.Buffer[=flag]
Parameter | Description |
---|---|
flag | A boolean value that specifies whether to buffer the page
output or not. False indicates no buffering. The server will send the output as it is processed. False is default for IIS version 4.0 (and earlier). Default for IIS version 5.0 (and later) is true. True indicates buffering. The server will not send output until all of the scripts on the page have been processed, or until the Flush or End method has been called. |
ตัวอย่าง
ตัวอย่าง 1
ในตัวอย่างนี้ จะไม่มีเอาต์พุตที่ส่งไปยังเบราว์เซอร์ก่อนที่ลูปจะเสร็จสิ้น หากบัฟเฟอร์ถูกตั้งค่าเป็น "เท็จ" มันจะเขียนบรรทัดไปยังเบราว์เซอร์ทุกครั้งที่ผ่านลูป
<%response.Buffer=true%>
<html>
<body>
<%
for i=1 to 100
response.write(i & "<br>")
next
%>
</body>
</html>
ตัวอย่าง 2
<%response.Buffer=true%>
<html>
<body>
<p>I write some text, but I will control when
the text will be sent to the browser.</p>
<p>The text is not sent yet. I hold it back!</p>
<p>OK, let it go!</p>
<%response.Flush%>
</body>
</html>
ตัวอย่างที่ 3
<%response.Buffer=true%>
<html>
<body>
<p>This is some text I want to send to the user.</p>
<p>No, I changed my mind. I want to clear the text.</p>
<%response.Clear%>
</body>
</html>
❮ การอ้างอิงออบเจ็กต์การตอบสนองที่สมบูรณ์