View Full Version : Plz give some idea about picture

03-23-2006, 07:22 AM

I am new to asp. Plz give some idea to insert a picture by using ASP. I want to know the detailed coding about this.

03-23-2006, 09:09 AM
Well, the result of your asp should be a valid image tag, like:

<img src="yourdirectory/yourimagefilename.jpg">

or for xhtml the minimum would be

<img src="yourdirectory/yourimagefilename.jpg" alt="your alt text" />

Now create Response.write statements which produce this, like

Response.Write "<img src=""yourdirectory/yourimagefilename.jpg"" alt=""your alt text"" />"

(double the quotes or otherwise they wont be in the output)

And you can also use variables to product the content of the src and alt attributes

Response.Write "<img src="""
Response.Write thevarthatholdsyourfilename
Response.Write """ alt="""
Response.Write thevarthatholdsyouralttext
Response.Write """ />"

Or combine this to a single line

Response.Write "<img src=""" & thevarthatholdsyourfilename & """ alt=""" & thevarthatholdsyouralttext & """ />"

03-23-2006, 04:53 PM
You need to give more info. Where is your image filename/url coming from?
Is it a from a database recordset or a filesystem object?

Another alternative is to break in and out of HTML

image_name = "myimage.jpg"
image_alt = "My Image"
<img src="<%=image_name%>" alt="<%=image_alt%>" />