Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Write Apostrophe (" / ') use

Status
Not open for further replies.

olegkot

Programmer
Aug 28, 2001
31
IL
Hi!

Can you explain how can I deal with Apostrophes (" / ') in string like:
Response.Write &quot;<input TYPE='button' NAME='B' ONCLICK='var newWindow = window.open('url','newWin','location')'>&quot;

which doesn't work (string syntax problem).

Thx in advance, oleg.
 
use like that
<%
'asp code goes here
%>
<input TYPE=&quot;button&quot; NAME=&quot;B&quot; ONCLICK=&quot;var newWindow = window.open('<%=aspurl%>','newWin','location')&quot;>
<%
'asp code goes here
%>

aspurl is the variable witch stores the url to be inserted at...

This sintax is more simple then Response.Write...
u insert an asp code between <% %> ________

George
 
Thx!

But any way do you know how to use Apostrophes ?

I'd like to know it generally. I red that to use Response.Write &quot;&quot; is faster than to put every where %>input tag / =variables <%.

oleg.
 
Here
Response.Write &quot;<input TYPE=&quot;&quot;button&quot;&quot; NAME=&quot;&quot;B&quot;&quot; ONCLICK=&quot;&quot;var newWindow = window.open('url','newWin','location')&quot;&quot;>&quot;

If u want to add quotes to an string put &quot;&quot; in place of &quot; ________

George
 
The problem you have is you are using sets of apostraphes inside other sets of apostrophes and this causes javascript errors.

Either use &quot; within your window.open command (use double &quot;&quot; within asp to indicate you wish to display &quot; character not end your string) as below:

Response.Write &quot;<input TYPE='button' NAME='B' ONCLICK='var newWindow = window.open(&quot;&quot;url&quot;&quot;,&quot;&quot;newWin&quot;&quot;,&quot;&quot;location&quot;&quot;)'>&quot;

Or use &quot; in your button definition and keep the ' in the onclick command as below:

Response.Write &quot;<input TYPE=&quot;&quot;button&quot;&quot; NAME=&quot;&quot;B&quot;&quot; ONCLICK=&quot;&quot;var newWindow = window.open('url','newWin','location')&quot;&quot;>&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top