Switch to full style
ASP Technology Tutorials Written By Members.
Post a reply

displaying double quotes in ASP

Mon May 14, 2012 11:31 pm

In this example we show how to write double quotes to the web page in asp, we need special handling when displaying double quotes, following is some cases on how to print double quotes:
1- Using
Code:
Response.Write """

Print: "
2- Using
Code:
Response.Write chr(34)

Print: "
3- To display quotes with strings :
Code:
Response.Write " string1 ""string2 string3 """

Print: string1 "string2 string3"

You can also use single quotes instead of double quotes to define the strings and avoid the need for escaping the quotes. Response.Write 'string1 "string2" "string3"' . This will also output the following string:
string1 "string2" "string3"



4- Writing quotes in HTML codes
Code:
Response.Write " <img src= ""image.gif""  />"

Print : <img src= "image.gif" />

The code uses double quotes to define a string containing the HTML image tag. Within the image tag, the "src" attribute is used to specify the source of the image, which is "image.gif". However, the way the code is written will result in an error. Because the attribute value of "src" is also enclosed in double quotes, the interpreter will consider the rest of the code as part of the attribute value. To correct this, you can escape the inner double quotes using a backslash (). Like this:

Response.Write " <img src= "image.gif" />"

Or you can use single quotes instead of double quotes to define the attribute value. Like this:

Response.Write " <img src='image.gif' />"

Both of the above-corrected codes will output the following HTML:

<img src='image.gif'>

In summary, this code snippet is trying to output an HTML image tag that displays an image named "image.gif". However, the way the code is written will result in an error because of the conflicting double quotes, but it could be fixed by either escaping the inner double quotes or using single quotes instead.



Post a reply
  Related Posts  to : displaying double quotes in ASP
 Add double quotes to text dynamically, on page load     -  
 usage of <q> and <blockquote> to add quotes to your HTML     -  
 Displaying Images using servlets     -  
 Displaying Images in a Gallery     -  
 displaying alert box in html     -  
 ASP.NET code for filling and displaying a DataGrid     -  
 Displaying images from database instead of the url from data     -  
 PHP forum- images displaying as codes     -  
 images,videos and signatures displaying as codes     -  
 double value be cast to a byte     -  

Topic Tags

ASP Strings, ASP Basics