UpdatePanel Constructor ()


Initializes a new instance of the UpdatePanel class.

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

Public Sub New

Use this constructor to initialize a new instance of the UpdatePanel class. To dynamically add an UpdatePanel control to a page, create a new UpdatePanel instance and then add child controls to the control object that is exposed by the instance's ContentTemplateContainer property.

The following example shows how to dynamically create an UpdatePanel control and add it to a page. When you click the button inside the UpdatePanel control, the message is refreshed with the date and time. Child controls are added by using the ContentTemplateContainer property.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">

    Protected Sub Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim lbl As Label
        lbl = Page.FindControl("Label1")
        lbl.Text = "Panel refreshed at " & DateTime.Now.ToString()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim up1 As UpdatePanel
        up1 = New UpdatePanel()
        up1.ID = "UpdatePanel1"
        Dim button1 As Button
        button1 = New Button()
        button1.ID = "Button1"
        button1.Text = "Submit"
        AddHandler button1.Click, AddressOf Button_Click
        Dim label1 As Label
        label1 = New Label()
        label1.ID = "Label1"
        label1.Text = "A full page postback occurred."
    End Sub

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>UpdatePanel Constructor Example</title>
    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" 
                               runat="server" />

.NET Framework
Available since 3.5
Return to top