AJAX UpdatePanel triggers, Conditional update mode
First of all I'd like to thank kowalskec for pointing me out the CopySourceasHTML VS add-in that will help me copy the code snippets from Visual Studio here without losing any text formatting.
Cheers buddy! =)
And now the task:
- The BugsGridView GridView control and BugsListTimeLabel Label in the Default.aspx page are encapsulated inside an UpdatePanel with an ID of BugsListUpdatePanel. The UpdatePanel does not update when other UpdatePanels on the page generate postbacks.
- The ActivityLabel Label control in the Default.aspx page is encapsulated inside an UpdatePanel with an ID of ActivityUpdatePanel. The UpdatePanel does not update when other UpdatePanels on the page generate postbacks. This UpdatePanel does not contain any other controls.
- The ActivityUpdatePanel UpdatePanel control in the Default.aspx page defines a trigger which causes the UpdatePanel to asynchronously refresh when the Click event of the ClearButton Button is raised.
- The BugsGridView_RowUpdated event handler in the _Default partial class refreshes the ActivityUpdatePanel UpdatePanel if changes have been made to the BugsGridView GridView control.
This will help me remember how to make the UpdatePanel do a postback by clicking a button outside of the panel, as well as call the UpdatePanel Update() method from code behind.
<!--Done:
The Default.aspx page contains a ScriptManager control with an ID of
BugsPageScriptManager.
-->
<asp:ScriptManager ID="BugsPageScriptManager" runat="server" EnablePartialRendering="true" />
<!--Done:
The BugsGridView GridView control and BugsListTimeLabel Label in the
Default.aspx page are encapsulated inside an UpdatePanel with an ID of
BugsListUpdatePanel. The UpdatePanel does not update when other
UpdatePanels on the page generate postbacks.
-->
<asp:UpdatePanel ID="BugsListUpdatePanel" runat="server" UpdateMode="Conditional"> <ContentTemplate>Bugs as of:
<asp:Label ID="BugsListTimeLabel" runat="server" Text="" /> <asp:GridView ID="BugsGridView" runat="server" AutoGenerateColumns="False" AutoGenerateEditButton="True" DataSourceID="BugsDataSource" OnRowUpdated="BugsGridView_RowUpdated"><
Columns>...</Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel><!--Done:
The ActivityLabel Label control in the Default.aspx page is encapsulated
inside an UpdatePanel with an ID of ActivityUpdatePanel. The UpdatePanel
does not update when other UpdatePanels on the page generate postbacks.
This UpdatePanel does not contain any other controls.
-->
<!--Done:
The ActivityUpdatePanel UpdatePanel control in the Default.aspx page
defines a trigger which causes the UpdatePanel to asynchronously refresh
when the Click event of the ClearButton Button is raised.
-->
<asp:UpdatePanel ID="ActivityUpdatePanel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="ActivityLabel" runat="server" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ClearButton" EventName="Click" /> </Triggers> </asp:UpdatePanel><asp:Button ID="ClearButton" runat="server" Text="Clear" OnClick="ClearButton_Click" />
protected void BugsGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
if (CheckForChanges(e, "Description", "Status", "AssignedTo"))
{
// Done:
// The BugsGridView_RowUpdated event handler in the _Default partial class
// refreshes the ActivityUpdatePanel UpdatePanel if changes have been made
// to the BugsGridView GridView control.
ActivityUpdatePanel.Update();
}
}