Is there a way to pass the value of "NULL" into a nullable field when calling an ASP.NET WebService from JavaScript?
I am currently calling the method in this manner from JavaScript:
ws_data.SaveTasks(eval({"MyValue":"null"}), OnSaveComplete, OnError, OnTimeOut);
However, I encounter an error (which triggers the OnError function):
null is not a valid value for Int32
Interestingly, if I pass a valid integer instead of "null", everything works perfectly fine.
I need guidance: What am I doing wrong? How can I correctly pass a 'null' value that will be interpreted as a NULL .NET object?
Any suggestions or ideas would be greatly appreciated!
P.S. Additional details are provided below.
Here is the key part of MyData declaration:
public class MyData
{
...
public int? MyValue { get; set; }
}
Declaration of the ASP.NET web service goes like this:
[WebService(Namespace = "...")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class ws_data : WebService
{
[WebMethod(true)]
public object SaveData(MyData data)
{...}
}
And the ws_data is referenced through ScriptManager:
<asp:ScriptManager runat="server">
<Services>
<asp:ServiceReference Path="/ws_data.asmx" />
</Services>
</asp:ScriptManager>