15.3. Using the Sys.Debug Class

The ASP.NET AJAX Library includes a helper class named Sys.Debug that can be used on the client side to write to trace logs, perform assert statements, and trigger a debug session in Visual Studio. Knowing how to use the Sys.Debug class can help simplify the process of ensuring that client-side functionality is performing properly and allow you to more easily view data passed from function to function in an application.

The Sys.Debug class is included in the release and debug versions of the MicrosoftAjax.js client-side script file shipped with ASP.NET AJAX. It defines several different functions that can be called to perform assertions, tracing, and debugging. The following table shows the different functions available on the Sys.Debug class.

Function NameDescription
assert(condition, message, displayCaller)Asserts that the condition parameter is true. If the condition being tested is false, a message box will be used to display the message parameter value. If the displayCaller parameter is true, the method also displays information about the caller.
clearTrace()Erases statements output from tracing operations.
fail(message)Causes the program to stop execution and break into the debugger. The message parameter can be used to provide a reason for the failure.
trace(message)Writes the message parameter to the trace output.
traceDump(object, name)Outputs an object's data in a readable format. The name parameter can be used to provide a label for the trace ...

Get Professional ASP.NET 3.5 AJAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.