getting string from server script to Client script
-
Hello, I am posting string data from C++ application, which uses activex webbrowser control, to ASP. The only way i can post this string in binary using safearray. Anyhow, I am able to successfully read this string in ASP server and assign it to client script varible using following statement. inputstr = "<%Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))%>" The problem is when i have some special characters like ",\r,\n... in my string. Is there a way to get this string to client sdie, so that i parse it and populate fields. Thanks
-
Hello, I am posting string data from C++ application, which uses activex webbrowser control, to ASP. The only way i can post this string in binary using safearray. Anyhow, I am able to successfully read this string in ASP server and assign it to client script varible using following statement. inputstr = "<%Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))%>" The problem is when i have some special characters like ",\r,\n... in my string. Is there a way to get this string to client sdie, so that i parse it and populate fields. Thanks
have u tried html encoding?
Ashish Sehajpal
-
have u tried html encoding?
Ashish Sehajpal
I tried Html encoding, and having same problem. I tried with simple \n in the input string: function DisPlayMsg() { var outputstr outputstr = "<%= Server.HTMLEncode(Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))) %>" alert(outputstr) } And after server process: function DisPlayMsg() { var outputstr outputstr = "abcd efgh" alert(outputstr) } Ann obviously it is erroring out.
-
I tried Html encoding, and having same problem. I tried with simple \n in the input string: function DisPlayMsg() { var outputstr outputstr = "<%= Server.HTMLEncode(Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))) %>" alert(outputstr) } And after server process: function DisPlayMsg() { var outputstr outputstr = "abcd efgh" alert(outputstr) } Ann obviously it is erroring out.
Ok, the Server is VBScript and the ClientSide is javascript so, you need to replace Chr(13) with "\r" and Chr(10) with "\n" VB wonnt encode these characters Giving you: function DisPlayMsg() { var outputstr outputstr = "abcd\r\nefgh" alert(outputstr) } Its a been a while since I have used ASP, but I dont get while you are calling Response.BinaryWrite. The response is the output of the ASP page which I gather is the above code, so I don't see why your calling Response.BinaryWrite? EDIT I see why you are calling BinaryWrite, your first post does not use the <%=%> method of writing out the value. try converting the BinaryRead output to a string and running a replace on it. James
James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
Mitch Hedbergmodified on Thursday, May 8, 2008 10:42 AM
-
Ok, the Server is VBScript and the ClientSide is javascript so, you need to replace Chr(13) with "\r" and Chr(10) with "\n" VB wonnt encode these characters Giving you: function DisPlayMsg() { var outputstr outputstr = "abcd\r\nefgh" alert(outputstr) } Its a been a while since I have used ASP, but I dont get while you are calling Response.BinaryWrite. The response is the output of the ASP page which I gather is the above code, so I don't see why your calling Response.BinaryWrite? EDIT I see why you are calling BinaryWrite, your first post does not use the <%=%> method of writing out the value. try converting the BinaryRead output to a string and running a replace on it. James
James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
Mitch Hedbergmodified on Thursday, May 8, 2008 10:42 AM
James Simpson wrote:
Its a been a while since I have used ASP, but I dont get while you are calling Response.BinaryWrite. The response is the output of the ASP page which I gather is the above code, so I don't see why your calling Response.BinaryWrite?
Hello, I am kind of new to ASP. so I was trying to different ways to extract string. I tried the replace, but same result(error).
<%Dim Binary11 Binary11 = Request.BinaryRead(Request.TotalBytes) Dim I, S For I = 1 To LenB(Binary11) S = S & Chr(AscB(MidB(Binary11, I, 1))) Next Replace S,"\r",Chr(13) Replace S,"\n",Chr(10) %> outputstr = "<%= Server.HTMLEncode(S) %>"
-
James Simpson wrote:
Its a been a while since I have used ASP, but I dont get while you are calling Response.BinaryWrite. The response is the output of the ASP page which I gather is the above code, so I don't see why your calling Response.BinaryWrite?
Hello, I am kind of new to ASP. so I was trying to different ways to extract string. I tried the replace, but same result(error).
<%Dim Binary11 Binary11 = Request.BinaryRead(Request.TotalBytes) Dim I, S For I = 1 To LenB(Binary11) S = S & Chr(AscB(MidB(Binary11, I, 1))) Next Replace S,"\r",Chr(13) Replace S,"\n",Chr(10) %> outputstr = "<%= Server.HTMLEncode(S) %>"
Try: S = Replace(S,Chr(13),"\r") S = Replace(S,Chr(10),"\n") I think you need to assign the return value of replace, and the parameters are the other way around (maybe??) James
James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
Mitch Hedberg -
Try: S = Replace(S,Chr(13),"\r") S = Replace(S,Chr(10),"\n") I think you need to assign the return value of replace, and the parameters are the other way around (maybe??) James
James Simpson Web Developer imebgo@hotmail.com P S - This is what part of the alphabet would look like if Q and R were eliminated
Mitch HedbergThanks James. Your replacement suggestion is working good. Only thing I have to solve now is handling '\' literal. If I have '\' in my string, it is missing when I assign it from server vbscript to cleint javascript. I tried replacing \ with \\, but no use.