TraceContext.IsEnabled Property
Indicates whether tracing is enabled for the current Web request.
[Visual Basic] Public Property IsEnabled As Boolean [C#] public bool IsEnabled {get; set;} [C++] public: __property bool get_IsEnabled(); public: __property void set_IsEnabled(bool); [JScript] public function get IsEnabled() : Boolean; public function set IsEnabled(Boolean);
Property Value
true if tracing is enabled; otherwise, false. The default is the setting of the enabled attribute in the <trace> section of a configuration file. If enabled is not set in a configuration file, the default is false.
Remarks
Use this flag to check whether your page or application should output tracing information before it writes anything to the trace log. You can set this property to true for a page by including a trace="true" attribute in the @ Page directive. To set the property to true for an entire application, set it in the application's Web.config file.
Note If you set this 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.
Example
[Visual Basic, C++] The following example demonstrates how you can check to see if tracing is enabled for a page before writing debugging code to it. The code iterates through the rows in a dataset, writing trace statements for each row in that dataset.
[Visual Basic] 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 [C++] if ( Context->IsEnabled ) { for (int i=0; i<ds->get_Tables()->get_Item(S"Categories")->get_Rows()->get_Count(); i++) { Trace::Write(S"ProductCategory",ds->get_Tables()->get_Item(S"Categories")->get_Rows()->get_Item(i)->get_Item(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
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
TraceContext Class | TraceContext Members | System.Web Namespace | @ Page