Solved

How to refresh the ASP.Net page after asynchronously updating the contents of page.

Posted on 2010-08-22
5
578 Views
Last Modified: 2013-12-17

Hi Experts,

         I am working on a ASP.Net web application wherein I am calling a class method Asynchronously to get the data from data base (using AsyncCallback) on page load. after the completion of this callback method raises an event. I'm handling the event on the asp.net page wherein I'm assigning the datasource to a grid view. Everything is going good except for the page is not getting refreshed after the event is getting fired. I have checked the datasource of the grid is assigned properly but the contents are not shown on the page.

My question is what can I do to refresh the contents of the page.


Please help its Urgent

Thanks and Regards
Paramhans
0
Comment
Question by:ParamhansDubey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:Stephan
ID: 33498755
Not sure if you mean that your data you have attached to the gridview needs to be refreshed, or the entire page.

If the first one: try GridView.DataBind();
0
 

Author Comment

by:ParamhansDubey
ID: 33499194
As I mentioned I'm calling the method Asynchronously so after the event is fired and after assigning the data source to the grid and after data binding it i want to post back the page to the server so that the latest contents of the page are visible on the page. I want to refresh the entire page on that event.
0
 
LVL 2

Expert Comment

by:SandyAgo
ID: 33500289
This is not possible. What you are trying to do is access the browser from the server side after the Page has already loaded. This cannot be done without some client initiation.

So, the code behind model is not really suitable for your purpose. However, an ugly way to do this would to be make the class method you are calling set a flag to define when it is finished, it will have to be on a per request/ session/ or global basis whichever suits your needs. Then put your GridView in an UpdatePanel, hide a Button on the page which causes an AsyncPostback after the page loads and inside the Button_Click method, make your PostBack wait until the data is loaded then call updatePanelName.Update() and complete the postback. Also make sure you dont start loading the data again duiring the postback.
0
 
LVL 3

Accepted Solution

by:
raaziq earned 500 total points
ID: 33540681
try adding this script for auto refresh based on a particular interval..

 <script>
        //AutoRefresh();
        AutoRefresh1();
        var parselimit
        function AutoRefresh1() {
            var limit = "0:45"

            if (document.images) {
                parselimit = limit.split(":")
                parselimit = parselimit[0] * 60 + parselimit[1] * 1
            }

            window.onload = beginrefresh1
        }

        function beginrefresh1() {
            if (!document.images)
                return
            if (parselimit == 1) {
                __doPostBack('Auto_Refresh', '');
            }
            else {
                parselimit -= 1
                curmin = Math.floor(parselimit / 60)
                cursec = parselimit % 60
                if (curmin != 0)
                    curtime = "Page will auto refresh in " + curmin + " minutes and " + cursec + " seconds!"
                else
                    curtime = "Page will auto refresh in " + cursec + " seconds!"
                window.status = curtime
                setTimeout("beginrefresh1()", 1000)
            }
        }
    </script>
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question