views:

539

answers:

1

I have returned object from signature device and when i make quick watch on it, it told me that its an array of long and when i pass it to web method in my code behind (vb.net) it gives me nothing. i need some help.. note: i'm using an activeX to capture the signature from the device.

this is javascript code :

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

this is my webmethod:

<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
+1  A: 

I don't know much about ASP.Net, but it seems like the PageMethods.Save function can't handle an array of long. Another possibility is that the sign variable is null in the javascript code.

Try adding

alert(sign);

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

console.log(sign);

instead. This way you'll make sure the sign var actually contains what you think it does.

If it indeed contains an array of numbers (javascript doesn't have a long type), maybe you need to convert it to something else before calling the PageMethods.Save function.

For example, this javascript snippet will convert sign into a space-separated string of numbers:

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

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

itsadok