Results 1 to 17 of 17

Thread: [RESOLVED] How to refresh page every second

  1. #1

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Resolved [RESOLVED] How to refresh page every second

    Hi guys.

    How do I refresh the page every second because my page is not showing because loading to the next page is too long.

    Here's what I have done so far.
    VB Code:
    1. Page.RegisterStartupScript("Timer", "<script type=text/javascript>setTiemout('document.location=document.location',1000)</script>")
    2.         SqlConnection1.Open()
    3.         SqlConnection2.Open()
    4.         Server.ScriptTimeout = 1000000
    5.         SqlSelectCommand2.CommandText = "SELECT t_mobile.t_fullname, t_mobile.t_empNo FROM t_mobile INNER JOIN t_Mmobile ON t_mobile.prime = t_Mmobile.prime WHERE (t_Mmobile.t_month LIKE '%" & MonthStr & "%') AND (t_Mmobile.t_year LIKE '%" & YearStr & "%')"
    6.         SqlSelectCommand2.ExecuteNonQuery()
    7.         SqlDataAdapter2.Fill(DataSet1)
    8.         EmpCount = 100
    9.         DataSet1.Reset()
    10.         Do While Not LoopCounter = EmpCount
    11.                              SqlSelectCommand2.CommandText = "SELECT t_mobile.t_fullname, t_mobile.t_empNo, t_mobile.t_total FROM t_mobile INNER JOIN t_Mmobile ON t_mobile.prime = t_Mmobile.prime WHERE (t_Mmobile.t_month LIKE '%" & MonthStr & "%') AND (t_Mmobile.t_year LIKE '%" & YearStr & "%')"
    12.                 SqlSelectCommand2.ExecuteNonQuery()
    13.                 SqlDataAdapter2.Fill(DataSet1)
    14.                 EmpNumber = Trim(DataSet1.Tables(0).Rows(LoopCounter - 1).Item(1))
    15.                 xcRange = xcWS.Range("B" & LoopCounter + 1)
    16.                 xcRange.Value = UCase(Trim(DataSet1.Tables(0).Rows(LoopCounter - 1).Item(0)))
    17.        Loop

    Apprceiate your help.

  2. #2

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Can Smart Navigation solve my problem?

    What is Smart Navigation anyway?

  3. #3
    Junior Member
    Join Date
    Sep 2005
    Posts
    29

    Re: How to refresh page every second

    Hi
    I don't know about your situation.But if you want to refresh a webform ,you can use Meta tag in html page.

    use this following Tag...

    <meta http-equiv="refresh" content=2>
    here 2 is every 2 seconds.you can give whatever you want.

    Thanks,
    Thiyagarajan.N

  4. #4

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    My situation is a webpage is taking too much time to load.

    It is so much that you will think that the program hung up on you.

    I will try what you have said after the program finished its task.

  5. #5

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Quote Originally Posted by thiyag2001
    Hi
    I don't know about your situation.But if you want to refresh a webform ,you can use Meta tag in html page.

    use this following Tag...

    <meta http-equiv="refresh" content=2>
    here 2 is every 2 seconds.you can give whatever you want.

    Thanks,
    Thiyagarajan.N
    Sorry it does not work. It still hungs up on me.

  6. #6
    Fanatic Member
    Join Date
    May 2005
    Posts
    608

    Re: How to refresh page every second

    It's taking long because it's timing out and it's not properly looping the DataSet.

    You have this:
    Do While Not LoopCounter = EmpCount
    But inside the loop, you don't increment LoopCounter + 1. So it always stays looping on the same record.

    To loop a DataSet, use:
    VB Code:
    1. For each dr as DataRow in DataSet1.Rows
    2. ..
    3. Next

    Also, on your 7 line, you Fill a DataSet, and then two lines later you clear it. That wastes time also.

    You are missing a good tune up on that code.

    Also, you want to do the oposite than refreshing the screen every 2 seconds. If you do that, every 2 seconds it will load the page. It's going to be imposible to use.

    SmartNavigation is mostly targeted to smooth the user interface while performing PostBacks. It's not related to this particular case.

    HTH
    HoraShadow
    Last edited by HoraShadow; Apr 21st, 2006 at 12:16 AM.
    I do like the reward system. If you find that my post was useful, rate it.

  7. #7

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Actually I did not posted the whole process because it will take 1000 lines of code and we don't want reading all of that. I have tested the program and it works 100% but the problem still remains that you will wait for more than 10 minutes.

    Code tune-up is not my problem as of now.

    But I will tune it up when my free time comes. Thanks for your concern.

    Currently I am having progress now. I am using the Response.Write and then Response.Flush but I am having errors when I use Response.Redirect.

    Can you guys help me.

  8. #8

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Last bump.

    f nobody replies then I will let the user die from waiting.

  9. #9
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: How to refresh page every second

    Why are u using Response.Write?

    Why are u refreshing every second? That's nuts. Refresh every 10-20-30 seconds. Not 1

    You posted code in your 1st post that has nothing to do with page refreshing.
    All I see is an evil loop hitting the DB 100x

    WOka

  10. #10

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Hmmm.... maybe I should paste all my codes so that you can how long does the process take.

    Ok here is the situation....

    I have 2 forms.

    The first form asks for month and year.

    The second form just does the processing and prompts the user to download the excel file.

    Fine. Fine. And fine.

    The problem left is that the process takes too long so I need some kind of progressbar.

    YES a progressbar. (That's the word I wanted to say.)

    But the problem is when I use a timer the page does not refresh.

  11. #11

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    I can't paste my code. There is a page error appearing.

  12. #12
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: How to refresh page every second

    This is because web is asynchronous.
    To do progress bars requires a lot of Java Script and a remote call back, called AJAX in 2005, in 2003 this is very hard to do.
    You cannot do a prog bar per-say, but you can create a "In progress" bar that just scrolls.
    Using a remote call back here is essential.

    This is very complicated stuff

    WOka

  13. #13

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Quote Originally Posted by Wokawidget
    This is because web is asynchronous.
    To do progress bars requires a lot of Java Script and a remote call back, called AJAX in 2005, in 2003 this is very hard to do.
    You cannot do a prog bar per-say, but you can create a "In progress" bar that just scrolls.
    Using a remote call back here is essential.

    This is very complicated stuff

    WOka
    Oh my God! I am such a newbie at this. Do you mean that I will still add a lot of codes just to do this:

    1. Pass the counter to the webpage.
    2. Refresh page or something.
    3. Fill color of table column so that it would look like a progress bar.

    Man if that is the case then I would let the user suffer waiting.

  14. #14

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Thanks anyway for the information.

  15. #15
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: How to refresh page every second

    No, you can't pass counters to the web page...well not like what you want to do I think.

    This would not work how you want it to.

    Web pages are async. What you could do, and i WOULDN'T do this, but i think it's what u're descibing is:

    Populate a grid with data.
    Flag row in grid to process. (could use viewstate for this)
    Set page to refresh every 5 seconds
    Check which row to process.
    Process row.
    Set next row to be processed.
    Display page.
    Page will refresh and process 2nd row.

    This is EVIL! and slow.

    You must do the call in a oner, ie one call to server.

    Doing this you cannot have a normal window progress bar.
    Like I said you can make an "In progress bar" that just scrolls randomly to show the user something is being done.

    To do this you must use remote call backs. 2003 doesn't support this, 2005 does.
    To do this is 2003 requires lots of evil code, and a decent level of .net programming.

    Do a google search for:

    ASP.NET remote callback

    Web design and apps are VERY VERy different from Win32 applications I am afraid. Many UI stuff cannot be achieved using asp.net that you can do in a windows form.



    Woka

  16. #16

    Thread Starter
    Hyperactive Member tommygrayson's Avatar
    Join Date
    Aug 2005
    Location
    In my Nissan Silvia
    Posts
    433

    Re: How to refresh page every second

    Quote Originally Posted by Wokawidget

    Web design and apps are VERY VERy different from Win32 applications I am afraid. Many UI stuff cannot be achieved using asp.net that you can do in a windows form.



    Woka
    Couldn't agree with you more. I will not pursue this crazy and evil quest as of now.

  17. #17
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] How to refresh page every second

    Remote Scripting has nothing to do with ASP.NET versions. It's been in use since the early days of the web and has only been rechristened as a brand new buzzword so that people can sell books, just like AJAX.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width