web 2.0

ASP Response.ContentType() - Response Object

ASP Response.ContentType() - Response Object Gets or sets the HTTP MIME type of the output stream.

ShotDev Focus:
- The HTTP MIME type of the output stream. The default value is “text/html”.

Example

asp_response_contenttype.asp

  1. <%@ Language=VBScript %>  
  2. <%  
  3. Option Explicit  
  4. Response.Buffer = TRUE  
  5. Response.ContentType = "application/vnd.ms-excel"  
  6. %>  
  7. <html>  
  8. <head>  
  9. </head>  
  10. <body>  
  11. <%  
  12. Dim Conn,strSQL,objRec  
  13. Set Conn = Server.Createobject("ADODB.Connection")  
  14. Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("db/mydatabase.mdb"),"" , ""  
  15. strSQL = "SELECT * FROM customer "  
  16. Set objRec = Server.CreateObject("ADODB.Recordset")  
  17. objRec.Open strSQL, Conn, 1,3  
  18. %>  
  19. <table width="600" border="1">  
  20. <tr>  
  21. <th width="91"> <div align="center">CustomerID </div></th>  
  22. <th width="98"> <div align="center">Name </div></th>  
  23. <th width="198"> <div align="center">Email </div></th>  
  24. <th width="97"> <div align="center">CountryCode </div></th>  
  25. <th width="59"> <div align="center">Budget </div></th>  
  26. <th width="71"> <div align="center">Used </div></th>  
  27. </tr>  
  28. <%  
  29. While Not objRec.EOF  
  30. %>  
  31. <tr>  
  32. <td><div align="center"><%=objRec.Fields("CustomerID").Value%></div></td>  
  33. <td><%=objRec.Fields("Name").Value%></td>  
  34. <td><%=objRec.Fields("Email").Value%></td>  
  35. <td><div align="center"><%=objRec.Fields("CountryCode").Value%></div></td>  
  36. <td align="right"><%=objRec.Fields("Budget").Value%></td>  
  37. <td align="right"><%=objRec.Fields("Used").Value%></td>  
  38. </tr>  
  39. <%  
  40. objRec.MoveNext  
  41. Wend  
  42. %>  
  43. </table>  
  44. <%  
  45. objRec.Close()  
  46. Conn.Close()  
  47. Set objRec = Nothing  
  48. Set Conn = Nothing  
  49. %>  
  50. </body>  
  51. </html>  

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_response_contenttype.asp

Screenshot

ASP & Response.ContentType()

ASP & Response.ContentType()

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.