Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Passing strings via an image


Message #1 by "Phil Bradwell" <p.bradwell@b...> on Sat, 23 Mar 2002 00:26:12
I have a results page and have place an image in one of the colums which I 
am going to use for the link to a detail page.
There are 2 different images which can appear on the results page and 
hence I have an If statement depending on which one is clicked. I am 
having trouble coding the Querystring in with the image, please can you 
help.

here is my code..
While ((Repeat1__numRows <> 0) AND (NOT RsSch.EOF)) 
%>
    <tr> 
      <td width="11%"> 
        
        <%if (RsSch.Fields.Item("Sch_Act").value) =1 then
		response.write "<a href=""reg_pupil.asp""><img 
src=""images/act.gif"" width=""80"" height=""22""</a>"
	  else 
	  Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value%></a>" <a><img src=""images/inactive.gif"" width=""80"" 
height=""22"" </a>"

HERE IS THE ERROR

Unterminated string constant??

Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value
---------------------------------------------------------------------------
-----------^

       end if%>
	    </td>
      <td width="45%"><%=(RsSch.Fields.Item("Sch_Name").Value)%></td>
      <td width="20%"><%=(RsSch.Fields.Item("Sch_City").Value)%></td>
      <td width="24%"><%=(RsSch.Fields.Item("Sch_County").Value)%></td>
    </tr>
    <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RsSch.MoveNext()
Wend
Message #2 by "Miguel A Castro" <castro04@c...> on Fri, 22 Mar 2002 16:55:20 -0800
Hi Phil,

I typically don't use the response.write method in this case.
I used something like this <td width="275" bgcolor="#FFFFCC" nowrap><a
href="reg_pupill.asp?Sh_ID=<%= objRST1("FieldNameHere")%>"><img
src="images/inactive.gif" width="80" height="20" border="0"></a></td>

This has always work for me.

Hope this help!

Mike


-----Original Message-----
From: Phil Bradwell [mailto:p.bradwell@b...]
Sent: Saturday, March 23, 2002 12:26 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Passing strings via an image


I have a results page and have place an image in one of the colums which I
am going to use for the link to a detail page.
There are 2 different images which can appear on the results page and
hence I have an If statement depending on which one is clicked. I am
having trouble coding the Querystring in with the image, please can you
help.

here is my code..
While ((Repeat1__numRows <> 0) AND (NOT RsSch.EOF))
%>
    <tr>
      <td width="11%">

        <%if (RsSch.Fields.Item("Sch_Act").value) =1 then
		response.write "<a href=""reg_pupil.asp""><img
src=""images/act.gif"" width=""80"" height=""22""</a>"
	  else
	  Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value%></a>" <a><img src=""images/inactive.gif"" width=""80""
height=""22"" </a>"

HERE IS THE ERROR

Unterminated string constant??

Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value
---------------------------------------------------------------------------
-----------^

       end if%>
	    </td>
      <td width="45%"><%=(RsSch.Fields.Item("Sch_Name").Value)%></td>
      <td width="20%"><%=(RsSch.Fields.Item("Sch_City").Value)%></td>
      <td width="24%"><%=(RsSch.Fields.Item("Sch_County").Value)%></td>
    </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  RsSch.MoveNext()
Wend

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


Message #3 by "Ken Schaefer" <ken@a...> on Mon, 25 Mar 2002 11:51:20 +1100
: Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
: (""Sch_ID"").value

should be:

Response.Write("<a href=""reg.asp?sch_ID=" &
RsSch.Fields.Item("Sch_ID").Value & """>Click here</a>")

Remember you can concatenation a string *inside* the outermost " delimiters.
You have a variable whose value you want to concatenate to the rest of the
string literal.

Cheers
Ken


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Phil Bradwell" <p.bradwell@b...>
Subject: [asp_web_howto] Passing strings via an image


: I have a results page and have place an image in one of the colums which I
: am going to use for the link to a detail page.
: There are 2 different images which can appear on the results page and
: hence I have an If statement depending on which one is clicked. I am
: having trouble coding the Querystring in with the image, please can you
: help.
:
: here is my code..
: While ((Repeat1__numRows <> 0) AND (NOT RsSch.EOF))
: %>
:     <tr>
:       <td width="11%">
:
:         <%if (RsSch.Fields.Item("Sch_Act").value) =1 then
: response.write "<a href=""reg_pupil.asp""><img
: src=""images/act.gif"" width=""80"" height=""22""</a>"
:   else
:   Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
: (""Sch_ID"").value%></a>" <a><img src=""images/inactive.gif"" width=""80""
: height=""22"" </a>"
:
: HERE IS THE ERROR
:
: Unterminated string constant??
:
: Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
: (""Sch_ID"").value
: --------------------------------------------------------------------------
-
: -----------^
:
:        end if%>
:     </td>
:       <td width="45%"><%=(RsSch.Fields.Item("Sch_Name").Value)%></td>
:       <td width="20%"><%=(RsSch.Fields.Item("Sch_City").Value)%></td>
:       <td width="24%"><%=(RsSch.Fields.Item("Sch_County").Value)%></td>
:     </tr>
:     <%
:   Repeat1__index=Repeat1__index+1
:   Repeat1__numRows=Repeat1__numRows-1
:   RsSch.MoveNext()
: Wend
:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #4 by "Brian Lowe" <brian.lowe@i...> on Tue, 26 Mar 2002 09:55:41
	>   Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value%></a>" <a><img src=""images/inactive.gif"" width=""80"" 
h> eight=""22"" </a>"

> HERE IS THE ERROR

> Unterminated string constant??

> Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
> ( ""Sch_ID"").value
> -----------------------------------------------------------------
> ----------^

You're within a script block, so where you have <%=RsSch.Fields.Item
(""Sch_ID"").value%> the opening symbol (<%) is not recognised and the 
next closing symbol (%>) closes the script block.

At this point your Response.Write is trying to write out
"<a href="reg.asp?Sch_ID=<%=RsSch.Fields.Item(""Sch_ID"").value

which has no closing quote, and so is an unterminated string...

To insert the recordset field value into your response string use
" & RsSch.Fields.Item("Sch_ID").value & " 
instead of <%=RsSch.Fields.Item(""Sch_ID"").value%>

Brian Lowe
---------@
Message #5 by "Phil Bradwell" <p.bradwell@b...> on Tue, 26 Mar 2002 21:31:26 -0000
Hi,

Thanks for you help that helps a great deal.. not only for this problem
but in general.

thanks again

Phil

-----Original Message-----
From: Brian Lowe [mailto:brian.lowe@i...]
Sent: Tuesday, March 26, 2002 9:56 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: Passing strings via an image


	>   Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
(""Sch_ID"").value%></a>" <a><img src=""images/inactive.gif"" width=""80""
h> eight=""22"" </a>"

> HERE IS THE ERROR

> Unterminated string constant??

> Response.write "<a href=""reg.asp?Sch_ID=<%=RsSch.Fields.Item
> ( ""Sch_ID"").value
> -----------------------------------------------------------------
> ----------^

You're within a script block, so where you have <%=RsSch.Fields.Item
(""Sch_ID"").value%> the opening symbol (<%) is not recognised and the
next closing symbol (%>) closes the script block.

At this point your Response.Write is trying to write out
"<a href="reg.asp?Sch_ID=<%=RsSch.Fields.Item(""Sch_ID"").value

which has no closing quote, and so is an unterminated string...

To insert the recordset field value into your response string use
" & RsSch.Fields.Item("Sch_ID").value & "
instead of <%=RsSch.Fields.Item(""Sch_ID"").value%>

Brian Lowe
---------@

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20


  Return to Index