VSMSDN > Online Developers Network
   
Welcome! Guest | Register | Login

Online Marketing Developers Network

Is about developers powered content. Every article submitted on VSMSDN helps other VSMSDN community members. So, share, discover, bookmark, and promote the ideas which can help grow you and as well as other developers.

Working with UpdateProgress AJAX.NET

If you are wondering why your UpdateProgress does not work, look at the code below. Normally while working with UpdateProgress we feel that everything looks correct and during compilation we don't get any errors.

This is the code:


<asp:UpdatePanel ID="update" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1"
runat="server" DynamicLayout="false">
<ProgressTemplate>
Processing...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Label ID="lblUpdate" runat="server">
4/28/1906 12:00:00 AM
</asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdate"
EventName="Click" />
</Triggers>
</asp:UpdatePanel>

<asp:Button ID="btnUpdate" runat="server" Text="Update"
OnClick="btnUpdate_Click" />


The above codes looks fine without any compilation errors but this will not give your desired results as you wanted in your flashy UpdateProgress like puting a GIF image or text for example "Just a moment...", "I am working on it..." during the PostBack event.

Here is the code with will help you achieve your desired goal:

<asp:UpdatePanel ID="update" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdateProgress ID="UpdateProgress1"
runat="server" DynamicLayout="false">
<ProgressTemplate>
Processing...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:Label ID="lblUpdate" runat="server">
4/28/1906 12:00:00 AM
</asp:Label>

<asp:Button ID="btnUpdate" runat="server" Text="Update"
OnClick="btnUpdate_Click" />

</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdate"
EventName="Click" />
</Triggers>
</asp:UpdatePanel>


Just notice, we have moved "btnUpdate" inside the ContentTemplate. If you keep the triger control outside the UpdatePanel, it will not work for obivious reason.

Now try out with this code and you will get what you wanted.