Passing JavaScript array up to code length?

I got back an object from the signature device and when I quickly observe it, it told me its array is long and when I pass it to the web method in my code behind (vb.net) it gives me nothing. I need help .. note: I am using activeX to capture a signature from a device.

this is the javascript code:

function OnSave() {
    var sign = document.FORM1.SigPlus1.SignatureString;
    PageMethods.Save(sign);
    }

      

this is my web method:

<WebMethod()> _
Public Shared Function Save(ByVal obj As Object) As String

    Dim obj1 As New PFSIGNATURELib.SigniShellSignature
    obj1.SignatureMime = obj
    obj1.SaveBitmapToFile(System.AppDomain.CurrentDomain.BaseDirectory() & "\sign1.bmp", 200, 200)

    Return "\sign1.bmp"
End Function

      

+2


source to share


1 answer


I don't know much about ASP.Net, but the function PageMethods.Save

doesn't seem to be able to handle an array of long ones. Another possibility is that the variable sign

is null in the javascript code.

Try adding

alert(sign);

      

in the middle is your Javascript function, or better yet, install firebug and do

console.log(sign);

      



instead of this. This way you make sure that the var sign actually contains what you think it is.

If it does contain an array of numbers (javascript has no type long

), you may need to convert it to something else before calling the function PageMethods.Save

.

For example, this javascript snippet converts sign

to a whitespace-separated string of numbers:

s = ""
for (i in sign) {
    s += sign[i] + " ";
}
sign = s

      

If you manage to pass this string to your web method, you can use some string parsing to get back the original array.

+1


source







All Articles