Manasa
Manasa

Reputation: 183

How do we display a progress bar in C# for a button click event in WebForm?

I have a button click event which does a lengthy function and takes time. So i want to display a progress bar. Can you let me know how can I do it.

I am very new to .NEt .. any help appreciated

Thanks in Advance, Amritha

Upvotes: 2

Views: 8375

Answers (1)

Cheng Chen
Cheng Chen

Reputation: 43523

I think this example is basic enough:

<form id="form1" runat="server">
   <asp:ScriptManager ID="sm" runat="server" />
   <asp:UpdateProgress runat="server" id="PageUpdateProgress">
         <ProgressTemplate>
             Loading...
         </ProgressTemplate>
   </asp:UpdateProgress>
   <asp:UpdatePanel runat="server" id="Panel">
         <ContentTemplate>
             <asp:Button runat="server" id="upd" onclick="updButton_Click" 
                   text="click to update" />
         </ContentTemplate>
   </asp:UpdatePanel>
</form>

In code behind updButton_Click takes a long time to update, during the period you will see Loading... on the page, you can change the text to a <img src="blabla" /> to make it more like a ProgressBar(such as a GIF moving-bar image)

Upvotes: 0

Related Questions