Control.Context 属性

定义

为当前 Web 请求获取与服务器控件关联的 HttpContext 对象。Gets the HttpContext object associated with the server control for the current Web request.

protected public:
 virtual property System::Web::HttpContext ^ Context { System::Web::HttpContext ^ get(); };
[System.ComponentModel.Browsable(false)]
protected internal virtual System.Web.HttpContext Context { get; }
member this.Context : System.Web.HttpContext
Protected Friend Overridable ReadOnly Property Context As HttpContext

属性值

与当前请求关联的指定 HttpContext 对象。The specified HttpContext object associated with the current request.

属性

示例

protected override bool OnBubbleEvent(object sender, EventArgs e)
{

   // Use the Context property to write text to the TraceContext object
   // associated with the current request.
   Context.Trace.Write("The ParentControl's OnBubbleEvent method is called.");
   Context.Trace.Write("The Source of event is: " + sender.ToString());

   return true;
}
<System.Security.Permissions.PermissionSetAttribute( _
    System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Function OnBubbleEvent(ByVal sender As Object, ByVal e As EventArgs) As Boolean

    ' Use the Context property to write text to the TraceContext object
    ' associated with the current request.         
    Context.Trace.Write("The ParentControl's OnBubbleEvent method is called.")
    Context.Trace.Write("The Source of event is: " + sender.ToString())

    Return True
End Function 'OnBubbleEvent

注解

此属性可让你访问当前 Web 请求的 HttpContext 对象。This property gives you access to the HttpContext object for the current Web request. 对象提供的属性可访问 ApplicationSessionRequestResponse 以及包含有关当前 HTTP 请求的信息的其他对象。The object provides properties that access the Application, Session, Request, Response and other objects that contain information about the current HTTP request. 它还提供了一些方法,可用于获取配置信息并为请求设置或清除错误。It also provides methods that allow you to obtain configuration information and set or clear errors for the request.

适用于

另请参阅