Forums
This topic is locked
mixing asp and javascript????
Posted 14 Dec 2002 02:42:45
1
has voted
14 Dec 2002 02:42:45 suhail kaleem posted:
hi !how do i equal the js variable value to the asp variable value ?
var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; " +
"charset=windows-1252\">\n<meta name=\"GENERATOR\" content=\"PageCreate\">\n" +
"<title>New Page</title>\n</head>\n<body> <br> <br> <%=session("varbody"%>" +
" <br> \n</body>\n</html>";
now if the session("varbody" conatins " or any other js iligal character it will produce a error in js script like line feeds/line breaks so how do i fix it ?
Thnaks
suhailkaleem
Replies
Replied 14 Dec 2002 07:54:57
14 Dec 2002 07:54:57 Owen Eastwick replied:
Ouch!
You're using a session variable to store the whole of the page body?
A session variable uses a portion of the servers RAM to store information, so if you store a large amount of information in a session variable, like a whole page which is likely to be equivalent to a couple of Mb or more you will be taking this amount for each and every user using the site.
So, lets say you are storing 5Mb of info in a session variable and there are 100 people using the site, that's 500Mb of the servers RAM you are using. As you can see, at this rate, you will quickly use up all the available RAM on the server and the performace of your web site will be terrible. If you are on a shared server, all the sites on that server will take a performance hit.
Session variables should be used with caution and only to store small amounts of data, like a username, which only takes up a few bytes.
Reference: msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasp/html/asptips.asp
In answer to your question, single quotes are valid HTML. e.g.
varHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
<%= varHTML %>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
You're using a session variable to store the whole of the page body?
A session variable uses a portion of the servers RAM to store information, so if you store a large amount of information in a session variable, like a whole page which is likely to be equivalent to a couple of Mb or more you will be taking this amount for each and every user using the site.
So, lets say you are storing 5Mb of info in a session variable and there are 100 people using the site, that's 500Mb of the servers RAM you are using. As you can see, at this rate, you will quickly use up all the available RAM on the server and the performace of your web site will be terrible. If you are on a shared server, all the sites on that server will take a performance hit.
Session variables should be used with caution and only to store small amounts of data, like a username, which only takes up a few bytes.
Reference: msdn.microsoft.com/library/default.asp?url=/library/en-us/dnasp/html/asptips.asp
In answer to your question, single quotes are valid HTML. e.g.
varHTML = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
<%= varHTML %>
Regards
Owen.
Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 14 Dec 2002 17:39:27
14 Dec 2002 17:39:27 suhail kaleem replied:
hi
Thanks for the info !
but what i am trying to do is to make asp fucntion that will completely convert HTML TO JAVASCRIPT
here is what i came up with but still there are errors
<pre id=code><font face=courier size=2 id=code>
<html>
<body>
<%
if request.form <> "" then
vart=replace(request.form("S1","""" ,"\"""
vart= replace (vart,"/","//"
vart= replace (vart,Chr(13),"\n"
vart= replace (vart,Chr(10),"\n"
response.write vart
response.write "<p><textarea rows=""4"" name=""S1"" cols=""22"">"&vart&"</textarea></p>"
end if
%>
<script language="JavaScript">
<!--
var pagehtml="<%=vart%>";
document.writeln(pagehtml);
document.writeln(" <p><textarea rows=\"4\" name=\"S1\" cols=\"22\">"+pagehtml+"<//textarea><//p>"
-->
</script>
<form method="POST">
<p> </p>
<p><textarea rows="4" name="S1" cols="22"></textarea></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
<p> </p>
</form>
</body>
</html>
</font id=code></pre id=code>
let me know if i ma going in teh write direction
Thanks
Edited by - suhailkaleem on 14 Dec 2002 17:46:34
Thanks for the info !
but what i am trying to do is to make asp fucntion that will completely convert HTML TO JAVASCRIPT
here is what i came up with but still there are errors
<pre id=code><font face=courier size=2 id=code>
<html>
<body>
<%
if request.form <> "" then
vart=replace(request.form("S1","""" ,"\"""
vart= replace (vart,"/","//"
vart= replace (vart,Chr(13),"\n"
vart= replace (vart,Chr(10),"\n"
response.write vart
response.write "<p><textarea rows=""4"" name=""S1"" cols=""22"">"&vart&"</textarea></p>"
end if
%>
<script language="JavaScript">
<!--
var pagehtml="<%=vart%>";
document.writeln(pagehtml);
document.writeln(" <p><textarea rows=\"4\" name=\"S1\" cols=\"22\">"+pagehtml+"<//textarea><//p>"
-->
</script>
<form method="POST">
<p> </p>
<p><textarea rows="4" name="S1" cols="22"></textarea></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
<p> </p>
</form>
</body>
</html>
</font id=code></pre id=code>
let me know if i ma going in teh write direction
Thanks
Edited by - suhailkaleem on 14 Dec 2002 17:46:34