This documentation is archived and is not being maintained.

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)

public bool IsEnabled { get; set; }
/** @property */
public boolean get_IsEnabled ()

/** @property */
public void set_IsEnabled (boolean value)

public function get IsEnabled () : boolean

public function set IsEnabled (value : boolean)

Property Value

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) { 
   for (int i=0; i<DS.Tables["Categories"].Rows.Count; i++) { 
     Trace.Write("ProductCategory", DS.Tables["Categories"].Rows[i][0].ToString());
    }
}
   

if (context.get_IsEnabled()) {
    for(int i=0;i<ds.get_Tables().get_Item("Categories").
            get_Rows().get_Count();i++) {
        Trace.Write("ProductCategory",
        ds.get_Tables().get_Item("Categories").
        get_Rows().get_Item(i).get_Item(0).ToString());
    }
}

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: