ComponentOne Window for ASP.NET AJAX: Window for ASP.NET AJAX Task-Based Help > Programming Tasks > Setting the ChildrenAsTriggers Property

Setting the ChildrenAsTriggers Property

The ChildrenAsTriggers property sets the ChildrenAsTriggers of the embedded UpdatePanels. When the ChildrenAsTriggers property of C1Window is set to True, the ChildrenAsTriggers of the UpdatePanels is set to True and UpdateMode is set to Always. If the C1Window's ChildrenAsTriggers property is set to False, the ChildrenAsTriggers of the UpdatePanels is set to False and UpdateMode is set to Conditional automatically.

The following steps provide an example of using the ChildrenAsTriggers property:

1.   Add the following markup to the .aspx page:

      Markup to Add

<cc1:C1Window

        id="C1Window1"

        height="155"

        runat="server"

        startposition="Manual"

        width="503"

        ShowOnLoad="true"

        ChildrenAsTriggers="true">

            <CaptionButtons>

                <CollapseExpandButton Visible="true" />

                <PinButton Visible="true" />

                <ReloadButton Visible="true" />

            </CaptionButtons>

            <ContentTemplate>

                <asp:Label ID="lblContent" runat="server" />

                <asp:Button ID="btnPostBack" runat="server"

                Text="PostBackFromC1Window"

                OnClick="C1Window1ChildrenPostBack" />

            </ContentTemplate>

            <StatusTemplate>

            <asp:Label ID="lblStatus" runat="server" />

            </StatusTemplate>

</cc1:C1Window>

2.   Switch to Code view and implement the ChildrenPostBack method to handle the button click event.

      Visual Basic

Protected Sub C1Window1ChildrenPostBack(sender As Object, e As EventArgs)

   lblContent.Text = "content updated at:" + DateTime.Now

   lblStatus.Text = "status updated at:" + DateTime.Now

End Sub

      C#

protected void C1Window1ChildrenPostBack(object sender, EventArgs e)

{

    lblContent.Text = "content updated at:" + DateTime.Now;

    lblStatus.Text = "status updated at:" + DateTime.Now;

}

3.   Run the project and at run time, click on the button within the C1Window control. Notice that both labels in the content and status areas are updated. This is because you set ChildrenAsTriggers to True.

4.   Return to the project and set the ChildrenAsTriggers to False. Run the application again and notice that label text will not be updated on clicking the button at run time.

5.   Add the following code to explicitly update content update panel in ChildrenPostBack:

      Visual Basic

Protected Sub C1Window1ChildrenPostBack(sender As Object, e As EventArgs)

   lblContent.Text = "content updated at:" + DateTime.Now

   lblStatus.Text = "status updated at:" + DateTime.Now

   TryCast(C1Window1.FindControl("c1contentupdatepanel"), UpdatePanel).Update()

End Sub

      C#

protected void C1Window1ChildrenPostBack(object sender, EventArgs e)

{

    lblContent.Text = "content updated at:" + DateTime.Now;

    lblStatus.Text = "status updated at:" + DateTime.Now;

(C1Window1.FindControl("c1contentupdatepanel") as UpdatePanel).Update();

}

6.   Run the project and notice that the content of the label is updated when the button is clicked.

7.   Add the following code to update the status label:

      Visual Basic

Protected Sub C1Window1ChildrenPostBack(sender As Object, e As EventArgs)

   lblContent.Text = "content updated at:" + DateTime.Now

   lblStatus.Text = "status updated at:" + DateTime.Now

   TryCast(C1Window1.FindControl("c1contentupdatepanel"), UpdatePanel).Update()

   TryCast(C1Window1.FindControl("c1statusupdatepanel"), UpdatePanel).Update()

End Sub

      C#

protected void C1Window1ChildrenPostBack(object sender, EventArgs e)

{

    lblContent.Text = "content updated at:" + DateTime.Now;

    lblStatus.Text = "status updated at:" + DateTime.Now;

(C1Window1.FindControl("c1contentupdatepanel") as UpdatePanel).Update();

(C1Window1.FindControl("c1statusupdatepanel") as UpdatePanel).Update();

}


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.