Solved

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

Posted on 2011-02-28
5
917 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
[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
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
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).

696 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