Advertisement
ASP_Volume2 Miscellaneous #42589

How to use ContentType!

This tutorial/code shows you how to use the contentType property of 'Response'. For people who never knew or didn't know how to use it.

AI

AI Samenvatting: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Broncode
original-source
<div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="3">Content 
 Type</font></strong><br>
 <em>Brought to you by MaKiT - http://www.makit.net/ </em></font></div>
<p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">The 
 content type property of 'response' lets you tell the the browser what type 
 of content there is.<br>
 I will show you two examples:</font></p>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FAFBDB">
 <tr>
  <td><font size="2" face="Courier New, Courier, mono">&lt;% @LANGUAGE 
   = VBScript %&gt;<br>
   &lt;%<br>
   Response.ContentType = &quot;application/msword&quot;<br>
   Response.Expires = 0<br>
   %&gt;<br>
   Hi!<br>
   This should be directly viewed in word through Internet Explorer.<br>
   It can be edited by the user and saved locally. This is very useful for<br>
   doing printable pages.<br>
   NB. Some users will get a open/save dialogue when opening the page and opening 
   will display the file in internet explorer but through MSword. Saving will 
   save the file as a *.doc.<br>
   NB. HTML tags are not interpretted (e.g &lt;br /&gt;).<br>
   Code brought to you by MaKiT - http://www.makit.net/</font></td>
 </tr>
</table>
<p align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> 
 </font><font size="2" face="Verdana, Arial, Helvetica, sans-serif">and...</font></p>
<table width="600" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FAFBDB">
 <tr> 
  <td><font size="2" face="Courier New, Courier, mono">&lt;% @LANGUAGE 
   = VBScript %&gt;<br>
   &lt;%<br>
   Response.ContentType = &quot;text/plain&quot;<br>
   Response.Expires = 0<br>
   %&gt;<br>
   There are a couple different responses to the plain text content type, either<br>
   opening the plain text in Internet Explorer or opening it in the persons 
   default<br>
   ASP editor.<br>
   Code brought to you by MaKiT - http://www.makit.net/</font></td>
 </tr>
</table>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">These are needed 
 in such things as sending a picture in a database to the client<br>
 or creating pictures in response to a users input.The default content type is 
 &quot;text/html&quot; and this doesn't need to be set as it is presumed.<br>
 Here is a list of popular content types (try experimenting):<br>
 ContentType=&quot;text/HTML&quot;<br>
 ContentType=&quot;text/plain&quot;<br>
 ContentType=&quot;image/GIF&quot;<br>
 ContentType=&quot;image/JPEG&quot;<br>
 ContentType = &quot;application/vnd.ms-powerpoint&quot;<br>
 ContentType = &quot;application/msword&quot;<br>
 ContentType = &quot;application/vnd.ms-excel&quot;<br>
 and so on...</font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">I am just trying 
 to show you how to use content type and not what all the properties are and 
 how to use them etc.<br>
 Thanks<br>
 MaKiT</font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><br>
 </font></p>
Originele reacties (3)
Hersteld van de Wayback Machine