AJAX progress does not work on initial page load

  • Thread starter Thread starter cindy
  • Start date Start date
C

cindy

I am using Ajax panels to show progress when a button executes a procedure
“Chart2_Load†to fill a chart. It works.
When the page loads initially the chart is filled with a default values and
the progress bar does not show during the initial page load, this is also the
longest time to wait for the load.

protected void Page_Load(object sender, EventArgs e)
{
if (!(Page.IsPostBack))
{
Chart2_Load(TextStart, TextEnd);

}
}

How can I show simple waiting message with Javascript or tell me what I am
doing wrong with Ajax to get the user a message during the first page load
seen above?

I have included the html for the panels below.
User requirements are to load the page initial with default values and not
ask them to click before chart loads first time.


<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<style type="text/css">……..
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="QuarterUpdatePanel" runat="server"
ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<asp:DataList id="dlButtons runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="PieUpdatePanel" runat="server"
OnLoad="PieUpdatePanel_Load" ChildrenAsTriggers="true" UpdateMode="Always">
<ContentTemplate>
<dotnet:Chart id="ChartPie" runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
ChildrenAsTriggers="true" UpdateMode="Always">
<ProgressTemplate>
<div id="OuterTableCellOverlay">
<div id="InnerTableCellOverlay">
<b>... LOADING ...</b>
<asp:Image ID="LoadImage" runat="server"
ImageUrl="~/Images/ajax-loader.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="ChartUpdatePanel" runat="server"
OnLoad="ChartUpdatePanel_Load">
<ContentTemplate>
<dotnet:Chart id="Chart5" runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
 
you need to do an ajax callback to load the chart. this will require
some javascript, as the panel's require a client event to fire them. the
easiest to just have a startup script fire the event.


Sys.Application.add_load(function() {
window.setTimeout(function(){
__doPostBack('<%=PieUpdatePanel.ClientId%>')
});
});


-- bruce (sqlwork.com)
 
I added this to the head
<head>
<script type="text/javascript">
Sys.Application.add_load(function() {
window.setTimeout(function(){
__doPostBack('<%=PieUpdatePanel.ClientId%>')
});
});
</script>
</head>

and I get this error

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS1061: 'System.Web.UI.UpdatePanel' does not contain
a definition for 'ClientId' and no extension method 'ClientId' accepting a
first argument of type 'System.Web.UI.UpdatePanel' could be found (are you
missing a using directive or an assembly reference?)

Source Error:



Line 45: Sys.Application.add_load(function() {
Line 46: window.setTimeout(function(){
Line 47: __doPostBack('<%=PieUpdatePanel.ClientId%>')
Line 48: });
Line 49: });
 
Please don't let this thread die I have posted the question in 3 other places
and this is the only faint response I have I am just trying bottom line to
get anything that will display to tell the user that the INITIAL page is
loading

I am new to AJAX and this worked when on the page there is a button and the
grid load due to the button click
On the initial page load the same procedure in the button click executes
using default values so actually once the page starts to load causing a
second postback in a panel won't work

If javascript is the answer I also cannot get anybody to get me a script
that works to display a simple message and I have used all those examples on
the web but either I am completely ignorant and placing the script wrong or
it is because I am using an aspx page with Ajax or I am clueless

Just asking given the page below what will display a simple message when
load STARTS and hide message when INITIAL LOAD COMPLETES. Also because of my
previous failures to implement how do I place on the page markup
As a <script> tag if so where
As a register startup if so when and where
I have been in these threads trying to get an answer since the middle of
June please help
 
To the best of my knowledge you cannot get the AJAX progress panel to display
when the page first loads. For it to display, as in a post-back, it needs to
be initialised within the page and it isn't when the page is first called.

You would also have the same problem trying to do this with javascript for
exactly the same reason, though I stand to be corrected.
 
Check the thread with title "page loading message showing before load
page and then gone on" in the scripting group...

It will show you an alternative.

Daniel.
 
I did something like this a while ago using ajax, it might help you, havent
got the code to hand but heres the basic method...

Use a ajax timer, update panel and update progress controls.

Start the timer running in page load, tick of 2 seconds.
 
Back
Top