คุณสมบัติประเภทเนื้อหา ASP
❮ การอ้างอิงออบเจ็กต์การตอบสนองที่สมบูรณ์
คุณสมบัติ ContentType ตั้งค่าชนิดเนื้อหา HTTP สำหรับอ็อบเจ็กต์การตอบกลับ
ไวยากรณ์
response.ContentType[=contenttype]
Parameter | Description |
---|---|
contenttype | A string describing the content type.
For a full list of content types, see your browser documentation or the HTTP specification. |
ตัวอย่าง
หากเพจ ASP ไม่มีชุดคุณสมบัติ ContentType ส่วนหัวของประเภทเนื้อหาเริ่มต้นจะเป็น:
content-type:text/html
ค่า ContentType ทั่วไปอื่นๆ:
<%response.ContentType="text/HTML"%>
<%response.ContentType="image/GIF"%>
<%response.ContentType="image/JPEG"%>
<%response.ContentType="text/plain"%>
ตัวอย่างนี้จะเปิดสเปรดชีต Excel ในเบราว์เซอร์ (หากผู้ใช้ติดตั้ง Excel):
<%response.ContentType="application/vnd.ms-excel"%>
<html>
<body>
<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
</tr>
</table>
</body>
</html>
❮ การอ้างอิงออบเจ็กต์การตอบสนองที่สมบูรณ์