Atribut ContentType ASP
Atribut ContentType menetapkan jenis konten HTTP bagi objek response.
Syarat:
response.ContentType[=contenttype]
Parameter | Deskripsi |
---|---|
contenttype |
String yang mendeskripsikan jenis konten. Untuk daftar lengkap jenis konten, lihat dokumentasi browser Anda atau spesifikasi HTTP. |
Contoh
Jika halaman ASP tidak menetapkan atribut ContentType, header content-type defaultnya seperti ini:
content-type:text/html
Beberapa nilai ContentType yang sering digunakan:
<%response.ContentType="text/HTML"%> <%response.ContentType="image/GIF"%> <%response.ContentType="image/JPEG"%> <%response.ContentType="text/plain"%> <%response.ContentType="image/JPEG"%>
Contoh ini akan membuka suatu lembar kerja Excel di browser (jika pengguna sudah memasang 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>