Page 249 - DCAP408_WEB_PROGRAMMING
P. 249
Unit 10: Working with Response Object
As the double quote (“) is used to indicate the beginning and end of a string, writing strings that Notes
contain double quotes can cause problems. So, one way is to use the single quote in your string.
At times, though you need to use double quotes. Putting two double quotes together will have
the effect of including a double quote within your string. For example, if you write
Response.Write (“<IMG SRC= “”banner.gif”” >”)
The browser will receive <IMG SRC= “banner.gif”>.
Server.HTML Encode can be used to send text encoded so that the browser will not interpret it as
HTML. For example,
Response.Write (Server.HTML Encode(“<P align=right>”)) will cause
<P align=right> to be printed to the screen without being interpreted as HTML.
Here is a list demonstrating the different ways of sending text containing quotation marks.
Notes Note that also demonstrates the use of Server.HTML Encode to send text so that the
browser does not interpret it.
List 1
Special characteristics with Response.Write
1: <%@Language=VBScript %>
2: <% Option Explicit %>
3: <HTML>
4: <BODY>
5: <A HREF= “index.html”>click here</a>
6: <BR>
7: <%
8: Response.Write(“< A HREF= “”index.html”” > click here</a>”)
9: Response.Write(“<BR>”)
10: Response.Write(“<A HREF= ‘index.html’>click here</a>”)
11: Response.Write(“<BR>”)
12: Response.Write(Server.HTML Encode (“<BR>”))
13: %>
14: </BODY>
15: </HTML>
Line 5 writes an HTML link statement normally. Line 8 writes the link statement using
Response.Write and double quotes. Line 10 writes the same statement again, but using single
quotes. Finally, line 12 demonstrates Server.HTML Encode.
USING<%=
<%=expression %> is equivalent to <% Response.Write (expression) %>.
This shortcut can be used only to send a single expression.
LOVELY PROFESSIONAL UNIVERSITY 243