Control.OnPreRender Method Home
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.NET Framework Class Library
Control.OnPreRender Method

Raises the PreRender event.

[Visual Basic]
Protected Overridable Sub OnPreRender( _
   ByVal e As EventArgs _
)
[C#]
protected virtual void OnPreRender(
 EventArgs e
);
[C++]
protected: virtual void OnPreRender(
 EventArgs* e
);
[JScript]
protected function OnPreRender(
   e : EventArgs
);

Parameters

e
An EventArgs object that contains the event data.

Remarks

This method notifies the server control to perform any necessary prerendering steps prior to saving view state and rendering content.

Example

[Visual Basic, C#, C++] The following example overrides the OnPreRender method in a custom server control. When the custom control is requested from an ASP.NET page, during the PreRender stage of page processing, OnPreRender method is called and the custom PreRender_Handler method sends its _message property value, "Parent Text was changed by PreRender method", to the page.

[Visual Basic] 

      Protected Overrides Sub OnPreRender(e As EventArgs)
         MyBase.OnPreRender(e)
      End Sub
            
      Private Sub PreRender_Handler(sender As Object, e As System.EventArgs)
         _message = "Parent Text was changed by PreRender method"
      End Sub


[C#] 

      protected override void OnPreRender(EventArgs e)
      {
         base.OnPreRender(e);
      }      
     
      private void PreRender_Handler(object sender,System.EventArgs e)
      {
         _message = "Parent Text was changed by PreRender method";
      }


[C++] 

protected:
      void OnPreRender(EventArgs* e)
      {
         Control::OnPreRender(e);
      }      
     
private:
      void PreRender_Handler(Object* /*sender*/,System::EventArgs* /*e*/)
      {
         _message = S"Parent Text was changed by PreRender method";
      }

[JScript] No example is available for JScript. To view a Visual Basic, C#, 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

Control Class | Control Members | System.Web.UI Namespace | Page | Control Execution Lifecycle

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View