Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatenating string in classic asp

Tags:

asp-classic

I am trying to concatenate image url (string) with img tag but i am not sure how to put " after src=. Please help to concatenate this.

response.write("<img src=" & '"' & rs("ProductImage") & '"' &" /><br/>")
like image 948
itsaboutcode Avatar asked Mar 18 '10 17:03

itsaboutcode


People also ask

Can you concatenate strings in C#?

You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.

What is the best way to concatenate strings in C #?

Concat() or + is the best way.

How do I concatenate columns in PostgreSQL?

PostgreSQL allows you to directly concatenate strings, columns and int values using || operator. Here is the SQL query to concatenate columns first_name and last_name using || operator. You can even concatenate string with int using || operator.


3 Answers

You have to double up the quotes:

Response.Write("<img src=""" & rs("ProductImage") & """ /><br/>")
like image 81
Thomas Avatar answered Sep 21 '22 02:09

Thomas


Since HTML can use double quotes or single quotes, why not just use single quotes for the HTML. So your code would look like this:

response.write("<img src='" & rs("ProductImage") & "' /><br/>")

The resulting output would look like this:

<img src='ProductImageUrl' /><br/>
like image 35
slolife Avatar answered Sep 20 '22 02:09

slolife


Another option is to use the chr function:

Response.Write("<img src=" & chr(34) & rs("ProductImage") & chr(34) & " /><br/>")

ascii code 34 is the double quote. We use this all the time when writing out HTML.

like image 41
burn0050 Avatar answered Sep 21 '22 02:09

burn0050