Editar

Compartir a través de


HideDisabledControlAdapter.Render(HtmlTextWriter) Method

Definition

Writes the associated Web control to the output stream as HTML.

protected public:
 override void Render(System::Web::UI::HtmlTextWriter ^ writer);
protected internal override void Render (System.Web.UI.HtmlTextWriter writer);
override this.Render : System.Web.UI.HtmlTextWriter -> unit
Protected Friend Overrides Sub Render (writer As HtmlTextWriter)

Parameters

writer
HtmlTextWriter

The HtmlTextWriter containing methods to build and render the device-specific output.

Examples

The following code example demonstrates how to override the Render method to pass the HtmlTextWriter object to the parent control for rendering if the associated control is enabled. This code example is part of a larger example provided for the HideDisabledControlAdapter class.

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
    if (Control.ID.StartsWith("Contoso"))
    {
        if (!Control.Enabled)
        {
            return;
        }
    }

    base.Render(writer);
}
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
    If (Control.ID.StartsWith("Contoso")) Then
        If (Not Control.Enabled) Then
            Return
        End If
    End If

    MyBase.Render(writer)
End Sub

Remarks

The Render method writes the associated WebControl control to the output stream as HTML.

By default, the .NET Framework calls on the Web server control's own Render method. However, once the Adapter property of that control is set, the .NET Framework will execute the adapter's implementation of the Render event over that of the associated control.

The Render event is used to perform modifications to the markup code that is rendered to a device browser. Control properties should be set prior to this phase of the life cycle and only the actual markup creation for the control done here. Changes made to the control in this stage of the life cycle are not saved to view state. For saving changes made to the control, override the OnPreRender event.

The Render event also allows derived classes to handle the event without attaching a delegate, which is the preferred technique for handling the event in a derived class.

Applies to

See also