Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Page Class
Page Methods
 VerifyRenderingInServerForm Method
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Page..::.VerifyRenderingInServerForm Method

Updated: November 2007

Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

Visual Basic (Declaration)
Public Overridable Sub VerifyRenderingInServerForm ( _
    control As Control _
)
Visual Basic (Usage)
Dim instance As Page
Dim control As Control

instance.VerifyRenderingInServerForm(control)
C#
public virtual void VerifyRenderingInServerForm(
    Control control
)
Visual C++
public:
virtual void VerifyRenderingInServerForm(
    Control^ control
)
J#
public void VerifyRenderingInServerForm(
    Control control
)
JScript
public function VerifyRenderingInServerForm(
    control : Control
)

Parameters

control
Type: System.Web.UI..::.Control

The ASP.NET server control that is required in the HtmlForm control.

ExceptionCondition
HttpException

The specified server control is not contained between the opening and closing tags of the HtmlForm server control at run time.

ArgumentNullException

The control to verify is nullNothingnullptra null reference (Nothing in Visual Basic).

Controls that are required to be inside <form runat=server> tags can call this method before they render so that an error message is shown if they are placed outside the tags. Controls that post back or depend on registered script blocks should call this method in an override of the Control..::.Render method. Pages that have a different way of rendering the server form element can override this method to throw an exception under different conditions.

Server controls that post back or use client-side script will not work if they are not enclosed in the HtmlForm server control (<form runat="server">) tags. These controls can call this method when they render to provide a clear error message when they are not enclosed in the HtmlForm control.

When you develop a custom server control, it is common to call this method when you override the Render method for any kind of input tag. This is particularly important if the input control calls GetPostBackEventReference, or if it emits client script. A composite server control does not need to make this call.

The following code example overrides the Page..::.Render method of a custom server control. When this control writes its content to a page, it uses the VerifyRenderingInServerForm method to make sure that the control appears between the opening and closing tags of an HtmlForm control.

Visual Basic
' Override the Render method to ensure that this control
' is nested in an HtmlForm server control, between a <form runat=server>
' opening tag and a </form> closing tag.
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)

    ' Ensure that the control is nested in a server form.
    If Not (Page Is Nothing) Then
        Page.VerifyRenderingInServerForm(Me)
    End If

    MyBase.Render(writer)

End Sub


C#
// Override the Render method to ensure that this control
// is nested in an HtmlForm server control, between a <form runat=server>
// opening tag and a </form> closing tag.
protected override void Render(HtmlTextWriter writer) {
    // Ensure that the control is nested in a server form.
    if (Page != null) {
        Page.VerifyRenderingInServerForm(this);
    }
    base.Render(writer);
}

J#
// Override the Render method to ensure that this control
// is nested in an HtmlForm server control, between a <form runat=server>
// opening tag and a </form> closing tag.
protected void Render(HtmlTextWriter writer)
{
    // Ensure that the control is nested in a server form.
    if (get_Page() != null) {
        get_Page().VerifyRenderingInServerForm(this);
    }
    super.Render(writer);
} //Render

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

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
I have tried to use this code over and over and can not get it to work.      jrmpat654   |   Edit   |  
I have tried to use this code over and over and can not get it to work. The examples are not working and not very useful.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker