user1300630
user1300630

Reputation:

ASP.Net UpdatePanel doesn't do PostBack

I have an ASP.Net page with a long, time-consuming function. I want it to show the "LOADING" word while computing, and show the results when it's done. Here's the code:

<asp:UpdatePanel UpdateMode="Always" runat="server" ID="upanel1">
        <ContentTemplate>
            <asp:Button ID="btnGetInfo"  runat="server" Text="Lekérés" OnClick="btnGetInfo_Click" />
        </ContentTemplate>
        <Triggers>
           <asp:AsyncPostBackTrigger ControlID="btnGetInfo" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upanel1">
    <ProgressTemplate>
        <div>
            LOADING</div>
    </ProgressTemplate>
</asp:UpdateProgress> 

It's almost working(I can see "LOADING" and after the btnGetInfo_Click function ended, "LOADING" disapperrs). I just need a PostBack when it's done.

I've found some similar problem, but the solutions didn't help me.

Thank You for the answers!

Upvotes: 0

Views: 1705

Answers (1)

pseudocoder
pseudocoder

Reputation: 4402

What is occurring when you click btnGetInfo is a partial page postback, which refreshes content inside the UpdatePanel ContentTemplate. The reason your GridView is not updating when you call DataBind() is because it is not inside the UpdatePanel ContentTemplate.

Triggering a full-page postback defeats the purpose of an UpdatePanel. I recommend that you put your GridView inside the ContentTemplate to fix the problem.

Upvotes: 1

Related Questions