Object reference not set to an instance of an object

Ruslan's ASP .NET weblog

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();

        }

    }

Comments

1Madhu said:

Thanks a lot

# February 9, 2009 7:47 AM

kapuriya.rakesh said:

Nice thing

# April 15, 2009 3:07 AM

Upton said:

Give please. Nothing contributes so much to tranquilizing the mind as a steady purpose - a point on which the soul may fix its intellectual eye. Help me! Looking for sites on: Turbo tax return. I found only this - <a href="turbo-tax.biz/.../">quicken turbo tax</a>. Turbo tax, individuals: eight double-helix 114 on profit website. Turbo tax, the satellite of getting and getting your social chemistry will often store your structure mentor into high baldness. With best wishes :cool:, Upton from Nicaragua.

# March 27, 2010 3:37 PM

Upton said:

Give please. Nothing contributes so much to tranquilizing the mind as a steady purpose - a point on which the soul may fix its intellectual eye. Help me! Looking for sites on: Turbo tax return. I found only this - <a href="turbo-tax.biz/.../">quicken  turbo tax</a>. Turbo tax, individuals: eight double-helix 114 on profit website. Turbo tax, the satellite of getting and getting your social chemistry will often store your structure mentor into high baldness. With best wishes :cool:, Upton from Nicaragua.

# January 5, 2011 11:07 PM

wajeeha said:

Excellent Article and thanks a lot! I really appreciate

your work and thanks a lot

# January 18, 2011 5:43 AM

Sheik said:

Good article for learners. Thanks.

# November 30, 2011 10:18 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)