How to run Ajax loading image for Crystal Report - c#

I have a Crystal Report in UpdatePanel. I want to use a ajax loading image when the crystalreportviewer loading data, but my code don't display the image.
<asp:UpdatePanel ID="uppnlAll" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlReport" runat="server" ScrollBars="Horizontal" Width="100%">
<CR:CrystalReportViewer ID="crlAll" runat="server" AutoDataBind="true" BackColor="AntiqueWhite" HasCrystalLogo="False" EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False" GroupTreeStyle-BackColor="#CCCCCC" PrintMode="ActiveX" Width="100%" ShowAllPageIds="true" />
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="crlAll" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress runat="server" ID="ajaxUpPro" DynamicLayout="false">
<ProgressTemplate>
<img src="../Images/ajax-loader1.gif" alt="Loading..."/> Loading...
</ProgressTemplate>
</asp:UpdateProgress>
Help me!

Try this way
<asp:UpdateProgress ID="ajaxUpPro" runat="server" AssociatedUpdatePanelID="uppnlAll"
DisplayAfter="2">
<ProgressTemplate>
<center style="height: 115px; width: 123px;" dir="ltr">
<img id="Img3" alt="Loading" src="Images/ajax-loader1.gif" runat="server" style="vertical-align: middle;
height: 71px; width: 100px;" /></center>
<cc1:AlwaysVisibleControlExtender ID="UpdateProgressVisibilityExtenderLeave3" runat="server"
TargetControlID="uppnlAll" VerticalSide="Middle" VerticalOffset="0" HorizontalSide="Center"
HorizontalOffset="0" ScrollEffectDuration=".1" />
</ProgressTemplate>
</asp:UpdateProgress>

Related

ModalPopupExtender calling .Show() does not work

I am using Visual Studio 2010 and for database I am using Entity Framework 4.
In my page , I have 3 tabs and in Second tab I used Grid view for displaying the Details of Employee . In that Grid View there are 2 image button one for Delete another for Edit. I want to open a popup box whenever I will click Edit Image Button.
The problems are
1. Popup box is appear for a second only.
2. Able to retrieve the row index of the Grid view. But no value is pass into other text box, it showing null value i.e. name0.Text= ""
In my .aspx page I have the following
For Image Button
<asp:ImageButton ID="edit" runat="server" CommandArgument='<%# Bind("EmpID")%>' CommandName="edituser" ImageUrl="image/images.jpg" ToolTip="Edit User Details" OnClick="EditUser_Clicked"> </asp:ImageButton>
For ModalPopupExtender
<asp:ToolkitScriptManager ID="Toolkitmgr" runat="server"></asp:ToolkitScriptManager>
<asp:HiddenField ID="EmpID" runat="server"
onvaluechanged="EmpID_ValueChanged"/>
<asp:ModalPopupExtender ID="mpedit" DropShadow="true" BackgroundCssClass="modalBackground"
PopupControlID="pnedit" CancelControlID="btnCancel"
runat="server" TargetControlID="EmpID"></asp:ModalPopupExtender>
<asp:Panel runat="server" ID="pnedit" CssClass="modalPopup" Style="display: block;width:525px">
***Some Code***
</asp:Panel>
In the server side code for the EditUser_Clicked event I have the following:
protected void EditUser_Clicked(object sender, EventArgs e)
{
ImageButton btndetails = sender as ImageButton;
GridViewRow row = (GridViewRow)btndetails.NamingContainer;
lblId.Text = GridView1.DataKeys[row.RowIndex].Value.ToString();
name0.Text = row.Cells[1].Text;
desig0.Text = row.Cells[2].Text;
dob0.Text = row.Cells[3].Text;
email0.Text = row.Cells[4].Text;
country0.Text = row.Cells[5].Text;
city0.Text = row.Cells[6].Text;
add0.Text = row.Cells[7].Text;
hq0.Text = row.Cells[8].Text;
rbtnListGender0.Text = row.Cells[9].Text;
mobno0.Text = row.Cells[10].Text;
this.mpedit.Show();
}
The code runs without error but modal popup is not visible. Please help me to find my mistake.
There 3 ways You can use Modal Popup using Update Panel.Try any one of this.
Modal Popup with UpdatePanel inside PopupPanel
<div style="background-color: White">
<asp:Button runat="server" ID="button4" Text="Launch Modal Popup1" />
<asp:Panel runat="server" ID="modalPanel3" Style="display: none">
<asp:UpdatePanel runat="server" ID="updatePanel3">
<ContentTemplate>
<asp:Label runat="server" ID="label4" Text="Label in UpdatePanel"></asp:Label>
<asp:Button runat="server" ID="Button5" Text="Click to Cause postback" OnClick="Button5_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" ID="Button6" Text="OK" />
<asp:LinkButton runat="server" ID="LinkButton1" Text="Cancel" />
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtender3" TargetControlID="button4"
PopupControlID="modalPanel3" OkControlID="Button6" CancelControlID="LinkButton1"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
</div>
2.Update Panel that contains a ModalPopup and its associated PopupPanel inside it
<asp:UpdatePanel runat="server" ID="updatePanel2" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Button runat="server" ID="button2" Text="Launch Modal Popup2" />
<asp:Panel runat="server" ID="modalPanel2" BackColor="AliceBlue" Style="display: none">
<asp:Label runat="server" ID="label5" Text="Label in UpdatePanel"></asp:Label>
<asp:Button runat="server" ID="postbackBtn" Text="Click to Cause postback" OnClick="postbackBtn_Click" /><br />
<asp:Button runat="server" ID="cancelBtn2" Text="OK" />
<asp:LinkButton runat="server" ID="okBtn2" Text="Cancel" />
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtender2" TargetControlID="button2"
PopupControlID="modalPanel2" OkControlID="okBtn2" CancelControlID="cancelBtn2"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
3.Update Panel that contains a ModalPopup; its PopupPanel has an UpdatePanel inside it
<asp:UpdatePanel runat="server" ID="outerUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="outerPanelTrigger" />
</Triggers>
<ContentTemplate>
<asp:Button runat="server" ID="outerPanelTrigger" Text="OuterPanelTrigger" /><br />
<br />
<asp:Button runat="server" ID="button1" Text="Launch Modal Popup3" />
<asp:Panel runat="server" ID="modalPanel1" BackColor="Pink" Style="display: none">
<asp:UpdatePanel runat="server" ID="updatePanel1" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label runat="server" ID="label1" Text="Label in UpdatePanel"></asp:Label>
<asp:Button runat="server" ID="updateLabel" OnClick="updateLabel_Click" Text="Click to Cause postback" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" ID="okBtn" Text="OK" />
<asp:LinkButton runat="server" ID="cancelBtn" Text="Cancel" />
</asp:Panel>
<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtender1" TargetControlID="button1"
PopupControlID="modalPanel1" OkControlID="okBtn" CancelControlID="cancelBtn"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
Are you using the latest version of AjaxControlToolkit?
In v16.1 the following bugs were fixed:
Item 27971 - Modal Popup incorrect z-index in tab container and
update panel
Item 28021 - Multiple ModalPopupExtenders z-index
issue

AsyncPostBackTrigger not working in Update Panel

Currently in my visual WebPart Contains update panel , but it not working, it post back the whole page
my code
My .aspx code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<div class="leftSection">
<asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="True">
<asp:ListItem Text="2015" Value="2015"></asp:ListItem>
<asp:ListItem Text="2016" Value="2016"></asp:ListItem>
</asp:DropDownList>
<div class="frmDate"><p>From</p>
<SharePoint:DateTimeControl ID="from" runat="server" DateOnly="True" AutoPostBack="true" MaxDate="8900-12-31" MinDate="2015-07-31" OnDateChanged="from_DateChanged" Calendar="1" IsRequiredField="true" ErrorMessage="Please Select From Date"/>
</div>
<div class="lastDate">
<p>
To
</p>
<SharePoint:DateTimeControl ID="to" runat="server" DateOnly="True" OnDateChanged="to_DateChanged" AutoPostBack="true" OnValueChangeClientScript="holidayDates()" IsRequiredField="true" ErrorMessage="Plaese Select To Date" />
</div>
</div>
<div class="rightSection">
<div id="testdiv" runat="server">
</div>
<asp:Label CssClass="hdn-lbl lblFromDate" ID="lblFromDate" runat="server" Text="Label"></asp:Label>
<asp:Label CssClass="hdn-lbl lblToDate" ID="lblToDate" runat="server" Text="Label"></asp:Label>
<asp:Label CssClass="hdn-lbl lblTotalHrs" ID="lblTotalHrs" runat="server" Text="Label"></asp:Label>
<asp:Button ID="save" runat="server" Text="SUBMIT" OnClientClick="return cal()" OnClick="save_Click" />
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="save" />
</Triggers>
</asp:UpdatePanel>
**after click on Submit Button it Post back total page **
Your save button is in your UpdatePanel by default you should use the ChildrenAsTriggers property of your UpdatePanel (set to true by default) and not AsyncPostBackTrigger.
Edit:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//...
</ContentTemplate>
</asp:UpdatePanel>
No external triggers just children as triggers, and default value as ChildrenAsTriggers is True equivalent to :
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">

Textbox inside Repeater not making UpdateProgress to trigger

I have following code in .aspx
<asp:UpdatePanel ID="upnGrid" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Repeater ID="rpt1" runat="server" OnItemDataBound="rpt1_ItemDataBound">
<ItemTemplate>
<table width="100%">
<tr>
<td align="right" width="25%">
<asp:Label ID="lbl1" Font-Bold="true" Font-Size="16px" Text=' <%# DataBinder.Eval(Container.DataItem,"Name") %>'
runat="server" />
</td>
<td>
<asp:HiddenField ID="hdn1" Value='<%# DataBinder.Eval(Container.DataItem, "Length") %>'
runat="server" />
</td>
<td>
<asp:TextBox ID="txt1" Font-Size="16px" Text='<%# DataBinder.Eval(Container.DataItem, "Value") %>'
AutoPostBack="true" Width="100px" OnTextChanged="txt1_TextChanged" runat="server" onkeydown="javascript:return OntxtEnter(event);"/>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<%--<Triggers>
<asp:AsyncPostBackTrigger ControlID="rpt1"/>
</Triggers>--%>
</asp:UpdatePanel>
code for UpdateProgress is at the end of aspx -
<asp:Panel ID="UpdateProgressPanel" runat="server">
<center>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="upnGrid"
DynamicLayout="true">
<ProgressTemplate>
<img src="../Images/loading.gif" alt="">
</ProgressTemplate>
</asp:UpdateProgress>
</center>
</asp:Panel>
<ajaxtoolkit:modalpopupextender id="ModalProgress" runat="server" targetcontrolid="UpdateProgressPanel"
popupcontrolid="UpdateProgress2" dropshadow="false" backgroundcssclass="modalBackground">
</ajaxtoolkit:modalpopupextender>
As suggested by some answers I made AsyncPostBackTrigger to be registered in code behind, like -
var control = e.Item.FindControl("txt1");
ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(control);
I am not getting, why it is not working.
Please suggest.
Edit
I tried putting only required textbox in UpdatePanel, It is showing following error
'System.Web.UI.Control' does not contain a definition for 'DataItem' and no extension method 'DataItem' accepting a first argument of type 'System.Web.UI.Control' could be found (are you missing a using directive or an assembly reference?)
Try modifying your UpdateProgress control as shown below:
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<asp:Panel ID="Panel1" runat="server">
<asp:Panel ID="Panel2" runat="server">
<asp:ImageButton ID="ibProgress" runat="server" ImageUrl="~/Images/progress.gif"
Visible="true" />Loading...
</asp:Panel>
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
You cannot use it in such a way. Because inside the repeater the TextBox ID is different.You have to follow different mechanism.

Show a Loading Message using master pages while page loads data asp.net

I have spent hours Googling and searching past questions but have struggled to get anywhere with those answers (be it I can't get it into my solution correctly or it isn't suitable for me as they don't have master pages).
My question is, I have a couple of asp.net pages which can take a while to load (sometimes 5 seconds+) as there is a lot of data being requested from a database on the Page_Load method. To stop users from thinking that the page has crashed and either refreshing the page or doing something else, I want to put up a Loading message hiding everything else on the page (apart from the menu) while it loads.
I am using ASP.Net 4.0 with master pages and coding in C#.
The one where I get the most success is using the UpdatePanel on my master page where the content template covers the contentplaceholder, however I know this is not the best way to go about it and anyway it only shows up once, i.e. The user logs in, the loading message appears and once all the data has loaded on the home page (dashboard.aspx) the loading message disappears, which is kind of what I want. However if the user goes away from that page and then clicks home the loading message never appears again, just takes a while to load. It also never appears for any other page that takes a noticeable time to load.
Below is the body of the master.aspx
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="page">
<div class="header">
<div class="title">
<h1>
Header
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In
]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" />
</span>! [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out"
LogoutPageUrl="~/Default.aspx" />
]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="false" Orientation="Horizontal" OnMenuItemClick="NavigationMenu_MenuItemClick">
<Items>
<asp:MenuItem Text="Home" />
<asp:MenuItem Text="About" />
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/loader.gif" />
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
And below is the page for the dashboard.aspx (a page which has a long loading time)
<asp:Panel ID="PanelWelcome" runat="server">
<h1>
Welcome
<asp:Label ID="LabelUserName" runat="server" Text="[User Name]" /> to your
personal Dashboard.</h1>
<table width="100%" cellpadding="5px">
<tr>
<td style="width: 70%" valign="top">
<asp:Panel ID="Panel2" runat="server">
<p>
</p>
<h4>
Up and Coming </h4>
<br />
<asp:GridView ID="GridViewItin" runat="server" Width="100%" HorizontalAlign="Left"
OnRowDataBound="GridViewItin_RowDataBound">
</asp:GridView>
</asp:Panel>
</td>
<td style="width: 30%">
<asp:Panel ID="PanelProfile" runat="server">
<asp:ImageButton ID="ImageButtonProfile" runat="server" ImageUrl="~/Images/BlankProfile.jpg"
Width="150px" /><br />
<h4>
Name:</h4>
<asp:Label ID="LabelPARname" runat="server" Text="[Person Name]"></asp:Label>
<h4>
Company:</h4>
<asp:Label ID="LabelBARname" runat="server" Text="[Company Name]"></asp:Label>
<h4>
Date of Birth:</h4>
<asp:Label ID="LabelPARdob" runat="server" Text="[DOB]"></asp:Label><br />
<asp:LinkButton ID="LinkButtonProfilePage" runat="server" OnClick="LinkButtonProfilePage_Click">More details...</asp:LinkButton>
</asp:Panel>
</td>
</tr>
</table>
</asp:Panel>
Could you please show me the best way to go about it and where I am going wrong? Also how I can hide the ContentTemplate when the UpdateProgress template is showing that would be great?
Thanks.
Okay so I figured it out what I was doing wrong, I thought I would post what I did to hopefully help someone else who might end up with the same issues...
Basically I hadn't thought about it logically. There are controls outside the update panel such as a NavigationMenu which would never fire the update progress because they had nothing to do with the Panel! I had to add triggers to the update panel to deal with all the things that happen outside the panel.
So, in my master page I had the following code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="NavigationMenu" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="progress" runat="server" DynamicLayout="true" DisplayAfter="0">
<ProgressTemplate>
<div id="overlay">
<div id="modalprogress">
<div id="theprogress">
<asp:Image ID="loader" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/loader.gif" />
Please wait...
</div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
Hopefully that will help someone else!
You can use UpdateProgress control. You can get it From Toll box under Ajax Extensions Tab.
I am describing you a scenario:
Suppose I have One Upadate Panel name UpdatePnl1 , In that I have a Button Say GO.when we hit on go it should redirect to another page. before that it will promt you please wait.
Now my Code will be like that
<asp:UpdatePanel ID="UpdatePnl1" runat="server">
<ContentTemplate>
<asp:Button ID="BtnGO" runat="server" Text="GO" onclick="BtnGO_Click"/>
</ContentTemplate>
</asp:Updatepanel>
Button click code:
protected void BtnGO_Click(object sender, EventArgs e)
{
Response.Redirect("Example.aspx");
}
Now here is the code for UpdateProgress what you need to add
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePnl1" >
<ProgressTemplate>
<asp:Label ID="LblWaitMsg" runat="server" Text="Processing Request, Please Wait..."></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
Note: Your page Should contain ScriptManager.

triggered button cause fullpostback

I've got an updatePanel and a button which triggered in it.
However, the button causes full postback instead of partial one.
Here's my Code:
<asp:Button ID="cEvent" runat="server" Text="צור יום" Width="80px"
Height="40px" Font-Size="Medium" onclick="cEvent_Click" CausesValidation="false"/>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel id = "updatePanel1" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="cEvent" EventName="Click"/>
</Triggers>
<ContentTemplate>
<div id="yesEve" runat="server" visible="false" style="width:95%; float:right; margin-left:5%; padding-top:20px; margin-bottom:20px;">
<table id="mytable" cellspacing="0" runat="server">
</table>
</div>
<div id="errorMsg" runat="server" visible="false" style="width:100%; text-align:center; float:right;">
<asp:label visible="true" ID="msg1" Font-Size="Medium" runat="server" Font-Bold="true" Text = "היום נמחק בהצלחה"></asp:label>
</div>
<div id="noEve" style="width:100%; padding-top:20px; float:right; text-align:center; margin-bottom:20px;" runat="server" visible="false">
<asp:label visible="true" ID="stamLabel" Font-Size="Medium" runat="server" Font-Bold="true" Text = "לא קיימים ימים פתוחים"></asp:label>
</div>
<asp:LinkButton ID ="remove" runat="server"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
I really need some help with that... i'm searching for hours all over the web to find an answer.
Thanks, Matan
In the code behind, you can try adding this line:
ScriptManager.GetCurrent(Page).RegisterPostBackControl(Button1);
There is nothing wrong with your code, you have a conflict somewhere with code(ClientIDs) you haven't show us or a JavaScript error breaking the page.
Here's a template for how to do this from a microsoft tutorial page:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
More information here:
microsoft tutorial

Categories