Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. getting string from server script to Client script

getting string from server script to Client script

Scheduled Pinned Locked Moved Web Development
c++comsysadmintoolshelp
7 Posts 3 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gangar
    wrote on last edited by
    #1

    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

    A 1 Reply Last reply
    0
    • G gangar

      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

      A Offline
      A Offline
      Ashish Sehajpal
      wrote on last edited by
      #2

      have u tried html encoding?

      Ashish Sehajpal

      G 1 Reply Last reply
      0
      • A Ashish Sehajpal

        have u tried html encoding?

        Ashish Sehajpal

        G Offline
        G Offline
        gangar
        wrote on last edited by
        #3

        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.

        J 1 Reply Last reply
        0
        • G gangar

          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.

          J Offline
          J Offline
          James Simpson
          wrote on last edited by
          #4

          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 Hedberg

          modified on Thursday, May 8, 2008 10:42 AM

          G 1 Reply Last reply
          0
          • J James Simpson

            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 Hedberg

            modified on Thursday, May 8, 2008 10:42 AM

            G Offline
            G Offline
            gangar
            wrote on last edited by
            #5

            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) %>"

            J 1 Reply Last reply
            0
            • G gangar

              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) %>"

              J Offline
              J Offline
              James Simpson
              wrote on last edited by
              #6

              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

              G 1 Reply Last reply
              0
              • J James Simpson

                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

                G Offline
                G Offline
                gangar
                wrote on last edited by
                #7

                Thanks 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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups