UpdateProgress control should show progressing until code executes.
I have set of code inside button_click(), progress bar should progress until code executes.
I can use Thread.sleep(5000), but my code takes more time and it varies from one request to another request. How can I resolve this? Please help me out.
<asp:ScriptManager runat="server">
</asp:ScriptManager>
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="loader.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div align="center">
<h1>Click the button to see the UpdateProgress!</h1>
<asp:Button ID="Button1" runat="server"
Text="Submit" OnClick="Button1_Click" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
Button handler code:
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
Related
I had my code to insert values into DB and after the data inserted the
ModalPopupExtender show and when click on OK button event fire to
reload the page . but I don't want all paged reload I tried to use
update panel but the OK event doesn't work .
<asp:Panel ID="PostPanel" runat="server" Style="display: none;">
<div class="modalPopup">
<div class="PopupBody">
<p class="ads-text">
GO </p>
</div>
<div class="Controls">
<div class="post">
<asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
OnClick="btnOkay_Click" />
</div>
</div>
</div>
</asp:Panel>
<cc1:ModalPopupExtender ID="ModelExtenderPost" OkControlID="btnOkay" runat="server"
TargetControlID="HiddenField22" PopupControlID="PostPanel" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:HiddenField ID="HiddenField22" runat="server" />
protected void btnOkay_Click(object sender, EventArgs e)
{
Response.Redirect(Request.Url.ToString(), true);
}
use updatepanel that is in asp.net
in top of your page :
<%# Page Title="" Language="C#" MasterPageFile="~/..." EnableEventValidation="false" AutoEventWireup="true" ....
and for ypur panel:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode= "Conditional">
<ContentTemplate>
<div class="modalPopup">
<div class="PopupBody">
<p class="ads-text">
GO </p>
</div>
<div class="Controls">
<div class="post">
<asp:Button Text="OK" runat="server" ID="btnOkay" ValidationGroup="AddUserpopup"
OnClick="btnOkay_Click" />
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnOkay" EventName ="Click" />
</Triggers>
</asp:UpdatePanel>
I have an ASP.NET application with a ListView. I get data from Active Directory and now I want a wait symbol for the time if the ListVew is building. I thought I would use a UpdateProgress Control from Ajax Control toolkit. But I don't know how I can use it if I click on a Button and the wait symbol (for example a gif) closes if the ListView is finished. :(
My CS file:
protected void btnBenutzerSuchen_Click(object sender, EventArgs e)
{
//If I click on this Button the gif must start
try
{
... // my ListView get data
this.myListView.DataSource = dv;
this.myListView.DataBind();
...
}
catch (Exception)
{
...
}
//If the ListView is finish the gif must close
}
How I can do this? Can I do this with the UpdateProgress like this:
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="?" >
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
My update.aspx file:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="~/BenutzerListe.aspx.cs" Inherits="BenutzerListe.BenutzerListe" %>
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripte/jquery-1.7.2.js" type="text/javascript"></script>
<script type="text/javascript" src="Scripte/jquery-ui-1.8.22.custom.min.js" ></script>
<script language="javascript" type="text/javascript">
// my javascript code
</script>
<link href="~/App_Theme/BenutzerListeStyle.css" type="text/css" rel="Stylesheet" />
<link href="App_Theme/jquery-ui-1.8.22.custom.css" type="text/css" rel="Stylesheet" />
<link href="App_Theme/PopUpDialog_Style.css" type="text/css" rel="Stylesheet" />
<style type="text/css">
#SuchTabelle
{
width: 587px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
<div class="header">
<br />
<table id="SuchTabelle" class="SuchTabelle" runat="server" border="0" width="100%">
<tr>
<th><asp:Label ID="id_SearchUser" runat="server" Text="lblSearchUser"></asp:Label></th>
<th class="txtBenutzerSuchen"><asp:TextBox ID="txtBenutzer" runat="server" Width="150px" ToolTip="Gesucht wird nach Vorname, Nachname, eMail , Abteilung und Telefonnummer"></asp:TextBox></th>
<th><asp:Label ID="id_location" runat="server" Text="lblLocation"></asp:Label></th>
<th class="DropDownList"><asp:DropDownList ID="dropWerk" runat="server" Width="200px" /></th>
<th>
<asp:Button ID="Button2" runat="server" Text="Suchen" onclick="btnBenutzerSuchen_Click" Width="150px"/>
</th>
</tr>
</table>
</div>
<div class="bodyList">
<asp:UpdatePanel ID="update" runat="server">
<ContentTemplate>
<asp:ListView> .... </asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="updatePro" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="update">
<ProgressTemplate>
<asp:Image ImageUrl="~/App_Theme/ajax_loader_circle.gif" runat="server" ID="waitsymbol" />
</ProgressTemplate>
</asp:UpdateProgress>
<hr />
</div>
</form>
</body>
</html>
First place your listview aspx code inside an update panel
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
// Place your list View Code here
<asp:ListView ..........
...... </asp:ListView>
</ContentTemplate>
<Triggers>
// If button is present outside update panel then specify AsynPostBackTrigger
<asp:AsyncPostBackTrigger ControlID="btnControlID" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
// Now Set AssociatedUpdatePanelID="up" in the UpdateProgress
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server" AssociatedUpdatePanelID="up" >
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Try to put your button within an UpdatePanel that contains the code may take a long time to execution, then associate the UpdateProgress control to the UpdatePanel. Code you may need is just like:
<asp:UpdatePanel ID="updatePanelMain" runat="server">
<ContentTemplate>
<asp:button runat="server" ID="btnBenutzerSuchen" OnClick="btnBenutzerSuchen_Click"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updatePanelMain" DisplayAfter="200">
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
I did a small example simulation a button click within an updatePanel. Pay attention to the attribute AssociatedUpdatePanelID which must be set, in order to show your progressTemplate.
default.aspx
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnDoSomething" runat="server" Text="Do Something"
onclick="btnDoSomething_Click" />
<asp:ListView> YOUR_LISTVIEW_GOES_HERE </asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout="true" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="progress">
<img src="images/ajax-loader-arrows.gif" /> please wait...
</div>
</ProgressTemplate>
</asp:UpdateProgress>
default.aspx.cs
protected void btnDoSomething_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
// or update listView
}
Show Progress Bar Using UpdateProgress Control in Asp.net
Refer This Link for more information
http://www.freshcodehub.com/Article/22/show-progress-bar-using-updateprogress-control-in-aspnet
<asp:UpdateProgress ID="prgLoadingStatus" runat="server" DynamicLayout="true">
<ProgressTemplate>
<div id="overlay">
<div id="modalprogress">
<div id="theprogress">
<asp:Image ID="imgWaitIcon" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/img/progress.gif"
Width="230px" /><br />
Please wait...
</div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="btnProgress" runat="server" Text="Show Progress" OnClick="btnProgress_Click" />
</ContentTemplate>
</asp:UpdatePanel>
I have a page that is taking a couple of seconds to load due to a lot of data being displayed.
How can i make it so that it plays a .gif animation until the data is ready to be displayed in a table instead of not having anything displayed?
How to set the table/content to display only after the loading is complete?
you can use asp.net ajax control, for example ScriptManager + UpdateProgress + UpdatePanel.
Here an example
<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>
protected void UpdateButton_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
Im having an issue with my progress bar. Now I have looked through all of the questions in overflow and Ive been through alot of google searching. I may have overlooked something, but Ill bet you anything this problem is something really simply I keep overlooking. Heres the deal.
My progress bar seems to work just fine. Im using ajax, everything is in the right panel, it fires immediatly when the button is pushed and actually it stops once the process is completed (although I have no idea how I did that). Please note, this is as simple as it gets. Its just a GIF, nothing special. Using Visual Studio 2010, SQL Server 2008, Ajax, and C#. Im not using a jquery or js, although I may have too.
My application is simple. It sends orders to a different server, so I am on the client side. Once the button is clicked, the orders are in the process of being sent. My Problem is, although the orders are being sent, when the progress bar stops, and the process is done, my labels (success or error) and order database tables do not fire. Why is this? I find this very odd because the application sends the orders, it functions 100%, but nothing changes on the user side.
Here is some code, if you need more then just say the word. Thank you all in advance!
protected void Page_Load(object sender, EventArgs e)
{
Initialize();
}
protected void Page_PreRender(object sender, EventArgs e)
{
}
protected void Button_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Button btn = (Button)sender;
KaplanFTP.BatchFiles bf = new KaplanFTP.BatchFiles();
KaplanFTP.Transmit transmit = new KaplanFTP.Transmit();
if (btn.ID == PutFTPButton.ID)
{//code
private void Initialize()
{//code if success/notsuccess labels will fire
Also here is the design code if it helps
<body>
<form id="form1" runat="server">
<div class="mainPanel">
<div>
<h3>Number of Batches Created Today: <asp:Label runat="server" style="display:inline;" ID="BatchesCreatedLbl"></asp:Label></h3>
</div>
<div id="batchestoprocessdiv">
<asp:Label runat="server" ID="BatchesToProcessLbl" Text="THERE IS AN ORDER BATCH TO PROCESS." CssClass="green"></asp:Label>
</div>
<asp:Label runat="server" ID="NoBatchesToProcessLbl" Text="There are no Order Batches to Process." CssClass="red"
Visible="false"></asp:Label>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="PutFTPButton" runat="server" onclick="Button_Click"
Text="Submit Orders" />
</ContentTemplate>
</asp:UpdatePanel>
<span class="red">COUNTDOWN TO SUBMISSION!</span>
<span id="timespan" class="red">
</span>
<asp:Label runat="server" ID="ErrorLabel" Visible="false" CssClass="red" Text="Error: "></asp:Label>
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<img alt="" class="style1" src="images/ajax-loader.gif" />
<br />
<asp:Label ID="Label1" runat="server" CssClass="red" Height="16px"
Text="Sending Orders....Please Wait"></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
<br />
<br />
<br />
<asp:Label runat="server" ID="SuccessLabel" Visible="false" CssClass="green" Text="Batch has been processed and uploaded successfully."></asp:Label>
</div>
<div id="OrdersInfoDiv" runat="server" visible="false">
<asp:GridView ID="BatchDetails" Caption="Details of orders ready to be sent" runat="server" AutoGenerateColumns="true"
CssClass="InfoTable" AlternatingRowStyle-CssClass="InfoTableAlternateRow" >
</asp:GridView>
</div>
<div id="OrdersSentDiv" class="mainPanel" runat="server" visible="false">
<h4>Sent Orders</h4>
</div>
</form>
<script src="js/SendOrders.js" type="text/javascript"></script>
</body>
Put all content those you want to refresh after download finished into UpdatePanel with UpdateMode="Always"
I'm using the AjaxToolkit in asp.net project c# code.
I have a script managet and an update pannel in my page. It all works perfect.
The only problem is that I can't figure out how to show the Ajax loader gif while the request is processed.
Any idea?
TY
se updateprogress of tool kit :hope this will help you
<asp:updatepanel id="ResultsUpdatePanel" runat="server">
<contenttemplate>
<div style="text-align:center;">
<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="ResultsUpdatePanel" dynamiclayout="true">
<progresstemplate>
<img src="support/images/loading.gif">
</progresstemplate>
</asp:updateprogress>
</div>
//your control code
</contenttemplate>
</asp:updatepanel>
If you use some styles to Div Loader will come at the center of the screen..so it looks good.
use this
<div style="text-align:center;position:fixed;left:40%;top:40%;padding-top:10px;">
<asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="ResultsUpdatePanel" dynamiclayout="true">
<progresstemplate>
<asp:Image ID="LoaderImage" runat="server" ImageUrl="~/images/loading.gif" />
</progresstemplate>
</asp:updateprogress>
</div>