views:

12

answers:

2

Given the following ASP.NET code:

[System.Web.Script.Services.ScriptService]
public class Quotes : System.Web.Services.WebService
{
    [WebMethod]
    public void Calculate(int param1, int? param2)
    {

etc.. How can I pass a null value to param2? If I don't pass the parameter at all, or I pass undefined, my error handler fires with "Invalid web service call, missing value for parameter: 'param2'".

A: 

Ok I was being stupid. I simply pass null!

http://stackoverflow.com/questions/801032/null-object-in-javascript

Sprintstar
A: 

If you're using C# 4.0 you could set a default value on the parameter.

ie

[WebMethod]
    public void Calculate(int param1, int? param2 = null)
    {...}
Dave