Export (0) Print
Expand All

Page.Trace Property

Gets the TraceContext object for the current Web request.

[Visual Basic]
Public ReadOnly Property Trace As TraceContext
[C#]
public TraceContext Trace {get;}
[C++]
public: __property TraceContext* get_Trace();
[JScript]
public function get Trace() : TraceContext;

Property Value

Data from the TraceContext object for the current Web request.

Remarks

Tracing tracks and presents the execution details about a Web request. For trace data to be visible in a rendered page, you must enable tracing at the page or application level.

Tracing on a page is disabled by default. To enable tracing for a page, use the @ Page directive: <%@ Page trace="true" %>. To enable tracing for an entire application, you must enable it in the application's configuration file, web.config, which resides in the root directory ofthe application. For more information, see ASP.NET Trace.

Example

[Visual Basic, C#] The following example demonstrates accessing the TraceContext.IsEnabled property and the TraceContext.Write method accessed through the Page.Trace property. This code calls the Trace.Write method only when tracing is enabled for the Page. If it is not enabled, this code will not run, which can help reduce overhead for your application.

[Visual Basic] 
If (Trace.IsEnabled)

  Dim I As Integer
  For I = 0 To DS.Tables("Categories").Rows.Count - 1

    Trace.Write("ProductCategory",DS.Tables("Categories").Rows(I)(0).ToString())
  Next
End If

[C#] 
if (Trace.IsEnabled)
{
  for (int i=0; i<ds.Tables["Categories"].Rows.Count; i++)
  {
    Trace.Write("ProductCategory",ds.Tables["Categories"].Rows[i][0].ToString());
  }
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace | @ Page | TraceContext | ASP.NET Trace

Show:
© 2014 Microsoft