Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.Net.ReturnComplexType Sample

vb/HandleColor.js

/* 
 * Client script *
 */

// It gets the default color
// from the Web service.
function GetDefaultColor()  
{
    // Call the Web service method to get 
    // the default color.
    Samples.AspNet.HandleColor.GetDefaultColor(
        SucceededCallback);  
     
}

// This is the callback function that 
// processes the complex type returned  
// by the Web service.
function SucceededCallback(result)
{
   
    // Read the values returned by the
    // Web service.
    var message = result.message;
    var rgb = result.rgb;
    var timeStamp = result.timeStamp;
    
    // Transform the rgb array into a string.
    var serverColor = rgb[0]+ rgb[1] + rgb[2];

    // Display the result.
    var displayResult = 
        document.getElementById("ResultId");
    displayResult.style.color = "yellow";
    displayResult.style.fontWeight = "bold";
    if (document.all) 
        displayResult.innerText = message + " " + timeStamp;
	else
	   // Firefox
	   displayResult.textContent = message + " " + timeStamp;
    displayResult.style.backgroundColor = "#" + serverColor;

}

if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();