Solved

How do i refresh a webpage without running the code behind again.

Posted on 2011-02-28
5
916 Views
Last Modified: 2012-05-11
Hi,
I have a webpage that has 5 gridviews on it. In the code behind I have a method that checks the status of an IP address on my network.  The results are then displayed on one of the gridview. The problem is, this method take up to a minute to run so everytime I load the webpage, it takes forever to load.

I then placed this method in a seperate thread so the webpage loads straight away and my method is running on the seperate thread. What I would like is for the method to finish and then update the gridview but I don't want the page to refresh and run the code behind again.

This is the client side code that I'm using to refresh the page
<meta http-equiv="refresh" content="100">

I've tried adding the following in my page load event but the thread seems to be triggered every time.

  If Not Page.IsPostBack Then
            secondThread.Start(pingDataTable)

        End If

Can anyone help me with this or suggest an alternative way I can update my gridview when the method has finished running.

One last thing, If I don't have the thread, my gridview does populate but like I said I have to wait a while before my page is displayed.

Thanks
0
Comment
Question by:Michael Roodt
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:sindhuxyz
ID: 34999165
You can control thread like this

Dim thread1 As New Thread(AddressOf yourmethod)
                    thread1.IsBackground = True
                    thread1.Start()

While (thread1.IsAlive )
thread.sleep(200)
end while
0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 34999386
Thanks sindhuxyz but can you explain  what the above does. I'm new to threads but from the above does your code not just make the thread sleep all the time. I need a way of saying when the method is done, update my gridview on the client side but at the same time don't run  the thread again when the update of the gridview takes place.

Thanks
0
 
LVL 5

Accepted Solution

by:
sindhuxyz earned 500 total points
ID: 34999621
the code will start thread with yourmethod and wait until it goes to end(with help of while). After End While, you can refresh your grid or do anything else

Hope, it is clear now.
0
 
LVL 2

Author Comment

by:Michael Roodt
ID: 35005666
With the method above my webpage still only loads once the thread is finished. I  need the page to load but at the same time use the page while the thread is running and when the thread is done. I need to refresh my grid.  How do I manually force the grid to refresh when the thread is finished.

Many thanks
0
 
LVL 2

Author Closing Comment

by:Michael Roodt
ID: 35014727
Didn't really get my my main point of the question answered and have found another solution
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tutorial for ebay api 3 35
ASP/VB email question 4 35
"Pause" execution of javascript function for x miliseconds 2 26
Index on a Table 6 15
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

777 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