Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TraceContext.IsEnabled Property

Gets or sets a value indicating whether tracing is enabled for the current Web request.

Namespace:  System.Web
Assembly:  System.Web (in System.Web.dll)

'Declaration
Public Property IsEnabled As Boolean

Property Value

Type: System.Boolean
true if tracing is enabled; otherwise, false.

Use this flag to check whether your page or application should output tracing information before it writes anything to the trace log.

The value of the IsEnabled property depends on the settings in the trace subsection of the system.web configuration section and the value of the trace attribute of the @ Page directive. The tracing option set in the page directive takes precedence over the option set in the configuration file. Setting the IsEnabled value programmatically takes precedence over both the page directive attribute and the configuration setting.

NoteNote

If you set the IsEnabled property to true for an entire application, you must explicitly set this property to false for any page in the application for which you do not want tracing information displayed.

The following code example demonstrates how you can determine whether tracing is enabled for a page. The code iterates through the rows in a dataset, writing trace statements for each row in that dataset.

If (Context.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
   

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft