O'Reilly logo

Professional ASP.NET 3.5 AJAX by Matt Gibbs, Dan Wahlin, Bill Evjen, Dave Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required