<h3>Trigger update from outside of the panel</h3>

        <pre data-sub="prettyprint:_">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>
        </asp:UpdatePanel>

        </pre>


        <h3>Nesting UpdatePanel Controls</h3>
        <p>
        Nested panels are useful when you want to be able to refresh specific regions of the page separately and refresh multiple regions at the same time. You can accomplish this by setting the UpdateMode property of both the outer and nested controls to Conditional. This causes the outer panel not to refresh its page region if only the inner panel is refreshing. However, if the outer panel is refreshed, the nested panels are refreshed also.  By default, the UpdateMode property of an UpdatePanel control is set to Always. This means that whenever a partial-page refresh is triggered, the UpdatePanel control will refresh the page region regardless of whether it was the UpdatePanel control that was triggered. To make sure that the UpdatePanel control will refresh only when it has been triggered, you can set the UpdateMode property of the UpdatePanel control to Conditional.

        </p>


        <pre data-sub="prettyprint:_">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
        <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
        </ContentTemplate>
        </asp:UpdatePanel>
        </ContentTemplate>
        </asp:UpdatePanel>

        </pre>


        <h3>Sibling UpdatePanel</h3>
        <p>
        For sibling updatepanels, if their updatemode is "conditional", then by default they only update their own area.  But you can use trigger in case when click one button in side of one panel to update the content in other panel.
        </p>

        <h3>Disabling Automatic Triggers </h3>
        <p>If you don't want your the control trigger update in update panel, (some time this is desireable when you want to trigger update by certain control, instead of all control in update panel), you need to set ChildrenAsTriggers to false</p>

        <pre data-sub="prettyprint:_">
        <%@ Page Language="C#" %>

        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

        <script runat="server">

        protected void Page_Load(object sender, EventArgs e)
        {
        this.Label1.Text = DateTime.Now.ToString();

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
        this.Label1.Text = DateTime.Now.ToString();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
        this.Label1.Text = DateTime.Now.ToString();

        }
        </script>

        <html xmlns="http://www.w3.org/1999/xhtml" >
        <head runat="server">
        <title>Untitled Page</title>
        </head>
        <body>
        <form id="form1" runat="server">
        <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False">
        <ContentTemplate>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:Button ID="Button2" runat="server" Text="inside" />
        <asp:Button ID="Button3" runat="server" Text="inside2" />

        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
        </Triggers>
        </asp:UpdatePanel>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="outside" />
        </form>
        </body>
        </html>

        </pre>


        <h3>Managing Triggers and Refreshing an UpdatePanel Programmatically</h3>
        <p>
        Sometimes, if you want more granular control how to update the update panel, you can do that programatically. In this case, you don't need to specify statically trigger in aspx page, you do that in you .net code.
        </p>


        <pre data-sub="prettyprint:_">
        protected void Page_Load()
        {
        ScriptManager1.RegisterAsyncPostBackControl(SurveyDataList);
        }

        protected void ChoicesRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
        {
        SortedList answers = this.AnsweredQuestions;
        RadioButtonList r = (RadioButtonList)sender;
        answers[r.ToolTip] = r.SelectedValue;
        this.AnsweredQuestions = answers;

        ResultsList.DataSource = this.AnsweredQuestions;
        ResultsList.DataBind();

        if (this.AnsweredQuestions.Count == SurveyDataList.Items.Count)
        SubmitButton.Visible = true;

        UpdatePanel1.Update();
        }
        </pre>


        <h3>Adding script to client using ScriptManager</h3>
        <p>You can add script to page either statically or dynamically, for example</p>
        <pre data-sub="prettyprint:_">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        <Scripts>
        <asp:ScriptReference Path="~/script/test.js" />
        </Scripts>
        </asp:ScriptManager>
        </pre>

        <pre data-sub="prettyprint:_">
        void Page_Load(object sender, EventArgs e)
        {
        ScriptManager smgr = ScriptManager.GetCurrent(Page);
        if (smgr == null)
        {
        throw new Exception("ScriptManager not found");
        }

        ScriptReference sref = new ScriptReference();
        sref.Path = "~/scripts/test.js";
        smgr.Scripts.Add(sref);

        }
        </pre>