Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Page.RegisterRequiresPostBack Method

Registers a control as one that requires post-back handling.

[Visual Basic]
Public Sub RegisterRequiresPostBack( _
   ByVal control As Control _
)
[C#]
public void RegisterRequiresPostBack(
 Control control
);
[C++]
public: void RegisterRequiresPostBack(
 Control* control
);
[JScript]
public function RegisterRequiresPostBack(
   control : Control
);

Parameters

control
The control to be registered.

Example

[Visual Basic, C#] The following example uses the RegisterRequiresPostBack method to require a customized text box control, customTextBox, to be posted back before any code associated with the text box will execute.

[Visual Basic] 
Sub Text_Change(sender As Object, e As EventArgs)
   myLabel.Text = "<b>Welcome " + myTextBox.Text + " to ASP.NET</b>"
End Sub 'Text_Change

Sub Page_Load(sender As Object, e As EventArgs)
   If Not IsPostBack Then
      Me.RegisterRequiresPostBack(myTextBox)
   End If
End Sub 'Page_Load

[C#] 
void Text_Change(object sender, EventArgs e)
{
   myLabel.Text = "<b>Welcome " + myTextBox.Text + " to ASP.NET</b>";
}
void Page_Load(object sender, EventArgs e)
{
   if(!IsPostBack)
      this.RegisterRequiresPostBack(myTextBox);
}

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

Page Class | Page Members | System.Web.UI Namespace

Show:
© 2015 Microsoft