To print a quotation mark (") in Classic ASP, double it inside a VBScript string or use Chr(34). Both methods work with Response.Write.
Quick example: place two double quotes inside a quoted string.
Response.Write "Raju told ""ASP is a better scripting language"""
Output: Raju told "ASP is a better scripting language"
VBScript uses double quotes to delimit string values. To include a quotation mark inside a quoted string, write it twice. Alternatively, generate the character using Chr(34). The HTML entity " is useful when writing HTML, but it is not a replacement for VBScript string quoting.
| Method | When to use | Result |
|---|---|---|
| Two quotes inside a string | Most VBScript text examples | One visible " |
Chr(34) | Joining text and quote characters | One visible " |
" | Generating HTML text | Quotation mark displayed by the browser |
The character code 34 represents a double quotation mark. It can be printed directly or stored in a variable for repeated use.
Print one double quotation mark.
Response.Write Chr(34)
Output: "
Build a sentence by concatenating a quotation-mark character.
Dim quoteChar, sentence
quoteChar = Chr(34)
sentence = "She said " & quoteChar & "Hello!" & quoteChar
Response.Write sentence
Output: She said "Hello!"
See joining strings using the ampersand operator for more concatenation examples.
Within a VBScript quoted string, "" represents one literal double quote. To print a double quote by itself, use a string literal made of four quote characters: an opening delimiter, two quotes for the character, and a closing delimiter.
Four double-quote characters produce one visible quotation mark.
Response.Write """"
Output: "
Include quoted words in the middle of a sentence.
Dim message
message = "Raju told ""ASP is a better scripting language"""
Response.Write message
Output: Raju told "ASP is a better scripting language"
Use doubled quotation marks more than once.
Dim message
message = "He said ""Hello"", and I replied ""Welcome""."
Response.Write message
Output: He said "Hello", and I replied "Welcome".
In VBScript, the backslash is not a general string-escape character. Do not use \" in place of doubled quotes. Also, a single quote (') outside a string begins a VBScript comment.
HTML attributes commonly use quotation marks. When the entire HTML tag is inside a VBScript string, double each embedded attribute quote so the generated HTML remains valid.
Write HTML containing a quoted class attribute.
Response.Write "<p class=""text-success"">Welcome to Plus2Net</p>"
HTML sent to the browser:
<p class="text-success">Welcome to Plus2Net</p>
Another option for displaying a quote as text in HTML is ". The browser decodes the entity into a visible quotation mark.
The HTML entity is inside an ordinary VBScript string.
Response.Write ""Learn Classic ASP""
Displayed output: "Learn Classic ASP"
" is an HTML entity. They are used at different stages of creating the page.To display the value of a session variable, read Session("userid") outside the quoted HTML string. Writing the expression entirely inside double quotes prints it as ordinary text instead.
Complete Classic ASP snippet showing the session value in a table.
<%
Dim userId
Session("userid") = "student42" ' Example value for this tutorial
userId = Session("userid")
Response.Write "<table class=""table table-bordered"">"
Response.Write "<tr><th>User ID</th><td>" & Server.HTMLEncode(CStr(userId)) & "</td></tr>"
Response.Write "</table>"
%>
Result: a table row showing User ID and student42. This example initializes the value for demonstration; production code should use an already-established session value and should not expose sensitive session identifiers.
Related lessons: Classic ASP session variables and Response.Write output.
Quotes in input are not automatically unsafe, but displaying untrusted text without output encoding can allow HTML injection. Use Server.HTMLEncode() for text inserted into HTML content; it is separate from VBScript quote escaping.
A form demonstration: the input uses HTML entities; the server HTML-encodes submitted text before displaying it.
<form method="post" action="">
<label for="message">Your message</label>
<input type="text" name="message" id="message" value="She said "Hello"">
<button type="submit">Display safely</button>
</form>
<%
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Dim message
message = Request.Form("message")
Response.Write "<p>You entered: " & Server.HTMLEncode(message) & "</p>"
End If
%>
See Classic ASP forms and Request.Form for reading form fields, and handling text line breaks when displaying multiline input.
When you need to change quotation marks in a text value, Replace() can search for Chr(34). This changes the text value itself; it does not perform HTML output encoding or make a SQL statement safe.
Replace double quotes with apostrophes.
Dim originalText, updatedText
originalText = "She said ""Hello""."
updatedText = Replace(originalText, Chr(34), "'")
Response.Write updatedText
Output: She said 'Hello'.
For formats that represent an embedded quote by repeating it (such as a quoted CSV field), you can double quotation marks in the text value.
Double quotation marks inside a value without changing the original text.
Dim originalText, escapedText
originalText = "She said ""Hello""."
escapedText = Replace(originalText, Chr(34), Chr(34) & Chr(34))
Response.Write Server.HTMLEncode(escapedText)
Displayed output: She said ""Hello"".
Related: the VBScript Replace() function and Classic ASP database connections.
| Problem | Likely cause | Solution |
|---|---|---|
| VBScript syntax error or unterminated string | A quote inside a string is not doubled | Replace an embedded " with "", or concatenate Chr(34) |
Visible text shows Session("userid") | The expression was placed inside a quoted HTML string | Concatenate the value outside the string and encode it for display |
Output includes " literally | The entity was HTML-encoded again | Use Chr(34) or emit the entity as appropriate for the output context |
| HTML attribute breaks | Embedded attribute quotes terminate the VBScript string | Double the attribute quotes in the VBScript literal |
| Apostrophe unexpectedly comments out code | Single quote appears outside a VBScript string | Use double quotes for VBScript string literals |
Use Response.Write Chr(34) or Response.Write """". Both produce one quotation-mark character.
Repeat each embedded quote. For example, "She said ""Hello""" represents the text She said "Hello".
No. Double the quote character or use Chr(34); do not rely on the backslash syntax used in other languages.
No. Doubling quote characters only controls VBScript source syntax. Use context-appropriate encoding when displaying submitted values, and validate input on the server.
" the same as Chr(34)?No. Chr(34) creates a quote character in a VBScript value; " is an HTML entity that the browser decodes while rendering HTML.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.