Using the GenerateScriptType Attribute

Listing 3. Using the GenerateScriptType attribute allows nested types within the CustomerDetails object to be exposed as standalone objects on the client side. This example shows how the Address type can be accessed and used directly.

function UpdateAddress()
{
    var cust = new Model.CustomerDetails();
    cust.CustomerID = $get("hidCustomerID").value;
    cust.Address = CreateAddress();
    CustomerService.UpdateCustomerAddress(cust,OnWSUpdateComplete);
}

function CreateAddress()
{
    var addr = new Model.Address();
    addr.Street = $get("txtStreet").value;
    addr.City = $get("txtCity").value;
    addr.State = $get("txtState").value;
    return addr;
}