Update Progress Bar While Inserting Data Into Database - asp.net

foreach (DataRow row in Employee.Rows)
{
//insert record into database. when record entered i need to update the progress
//bar on client side.
}
How to solve my Problem?

Take your Insert Button in Update Panel and assign Update Progress to your Update Panel as shown below.
<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel" runat="server">
<ProgressTemplate>
<div>
<asp:Image ID="Image" runat="server" ImageAlign="Middle" ImageUrl="Images/loading.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>

Related

Show UpdateProgress in update panel only when a particular event is occur

I have an update panel which contains two buttons one is submit and other is cancel.
Now i want when i will click on submit button then progress bar displays.
But when i will click on cancel button it should not display.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br />
<asp:UpdateProgress runat="server" ID="PageUpdateProgress" DisplayAfter="0" >
<ProgressTemplate>
<img src="../images/ajax-loader.gif" alt="Loading...." /><br />
</ProgressTemplate>
</asp:UpdateProgress>
<asp:LinkButton ID="lnkSubmit" runat="server" CssClass="lnk">Submit</asp:LinkButton>
<asp:LinkButton ID="lnkCancel" runat="server" CssClass="lnk">Cancel</asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
Please help me i am tired to try to solve it.
Thanks ,Rajbir

ProgressBar show in GridView in asp.net

In Gridview cell, I have to show ProgressBar in ASP.NET.
I am using async event in ASP.NET 4.0
Could you guide me to find the solution for it?
I assume you mean from the client side ajax. If not, can you elaborate? If you are using a simple update panel you can just drop a Update Progress control on the page and put whatever you want to display as "progress" in the ProgressTemplate.
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" 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="UpdateButton" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</form>

Progress bar in Ajax Update panel not showing

I wrote the following
<asp:UpdatePanel ID="Download" runat="server">
<ContentTemplate>
<asp:Label ID="lblMessage" runat="server"
Text="Click the link to download the Report:"></asp:Label>
<asp:LinkButton ID="lbtnDownload" runat="server"
OnClick="lbtnDownload_Click" Text="Download Excel Sheet"></asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="lbtnDownload"/>
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="download1" runat="server" AssociatedUpdatePanelID="Download">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl"indicator.gif" " />
</ProgressTemplate>
</asp:UpdateProgress>
But the progress bar image is not showing can any one tell why
Remove the following: <asp:PostBackTrigger ControlID="lbtnDownload"/>
Ok, first thing to check is that you are definitely posting back successfully, also add a delay interval:
<asp:UpdateProgress DisplayAfter="0" ID="download1" runat="server"
AssociatedUpdatePanelID="Download">

Update panel can not find the button which trigger it

I have a button is inside a another table(s) inside the update panel.
<Update panel>
<ContentTemplate>
<table>
<table>
<Button>
<table>
<table>
</ContentTemplate>
</Update panel>
I would like to add a button to Update panel's trigger.
But am getting an err says "Update panel can not find the button which trigger it".
I am getting "Sys.Webforms.PageRequestmanagerParseErrorException: This message recieved from manager could not be parsed. Common cause for this error are when response is modified by response.write"
Please help!
PostBackTrigger example:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btn1" runat="server" Text="Button 1-Partial Postback" />
<asp:Button ID="btn2" runat="server" Text="Button 2-Full Postback" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btn2" />
</Triggers>
</asp:UpdatePanel>

UpdateProgress with an UpdatePanel

I want to show the UpdateProgress on page A when a user clicks on the "Next" button to go to next page. The next page is Page B, which has heavy data loading.
When the button is clicked, it doesn't show the UpdateProgress.
What's missing from this code, and how can it be made to show?
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate >
Please wait ...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNext" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="btnCancel" runat="server" TabIndex="1" Text="Cancel"onclick="btnCancel_Click" />
<asp:Button ID="btnNext" runat="server" TabIndex="2" Text="Next" onclick="btnNext_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Try setting DisplayAfter to a very small value to make the progress indicator appear immediately, e.g.:
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" AssociatedUpdatePanelID="UpdatePanel1" DisplayAfter="1">
Couple of things to try:
1) Move the UpdateProgress control inside the UpdatePanel
2) Remove the AssociatedUpdatePanelID attribute from the UpdateProgress tag
I'm banking on Option 1 doing the trick.
EDIT
Here is a non-ProgressTemplate way, using client-side event handlers:
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args)
{
// some code to show image, e.g:
document.getElementById('somedivwhichasimage').className = 'show';
}
function EndRequestHandler(sender, args)
{
// some code to hide image, e.g:
document.getElementById('somedivwhichasimage').className = 'hidden';
}
</script>
Add this code on the code behind of this page.
protected void btnNext_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
}
Hope this helps!!
Edit:
Follow this link:
http://msdn.microsoft.com/en-us/library/bb386421.aspx
Adding the code from aspx page that I tried and is working,
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="Server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate >
<asp:Label ID="lblwait" runat="server" Text="Please wait.."></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="btnCancel" runat="server" TabIndex="1" Text="Cancel" />
<asp:Button ID="Button1" runat="server" TabIndex="2" Text="Next" onclick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
try putting UpdateProgress control inside UpdatePanel. and that should work for you.
hope that helps!

Resources