asp.net Update Panel

Discussion in 'Software' started by Ryan_Zim, Jul 2, 2009.

  1. Ryan_Zim

    Ryan_Zim

    Joined:
    Jun 29, 2009
    Messages:
    1
    Hi All,

    I'm new to this forum, so if this is the wrong place to post this question, sorry, please let me know where I should post it.

    I am trying to get an UpdatePanel to refresh dynamically (in the middle of a function without an event firing). You only seem to be able to update it on an event firing. One option is to get a timer control to check for a status update from the function but I am not sure what sort of overhead the timer control will have if it is firing all the time (it is quite time sensitive so the timer interval would have to be quite short).

    I have a little sample code for the update panel to try and show you what I wish to do.

    Please could you shed some light on whether it is possible to update an updatepanel dynamically and how. Also an idea of what sort of resources the timer control takes up in case I am forced to go with that solution.

    This is a basic example of how it works with the timer.


    Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub btntest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btntest.Click
    If Timer1.Enabled = False Then
    Timer1.Enabled = True
    btntest.Text = "Stop Loop"
    Else
    Timer1.Enabled = False
    btntest.Text = "Start Loop"
    End If
    End Sub
    Protected Function UpdateMyPanel(ByVal timedelay As Long, ByVal TextToSend As String) As Boolean
    ListBox1.Items.Add(TextToSend & Now())
    Threading.Thread.Sleep(timedelay)
    End Function

    Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim Sucess As String
    If ViewState("TickTocker") Mod 2 Then
    Sucess = UpdateMyPanel(1000, "Tock" & ViewState("TickTocker"))
    Else
    Sucess = UpdateMyPanel(1000, "Tick" & ViewState("TickTocker"))
    End If
    ViewState("TickTocker") = ViewState("TickTocker") + 1
    End Sub
    End Class


    I would want something more like this but it seems to do a full postback at the end of the sub instead of passing the items as they happen 1 by 1.

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim Sucess As String
    Dim i As Integer
    For i = 1 To 20
    If ViewState("TickTocker") Mod 2 Then
    Sucess = UpdateMyPanel(1000, "Tock" & ViewState("TickTocker"))
    Else
    Sucess = UpdateMyPanel(1000, "Tick" & ViewState("TickTocker"))
    End If
    ViewState("TickTocker") = ViewState("TickTocker") + 1
    Next i
    End Sub

    Any help would be appreciated.

    Ryan
    Ryan_Zim, Jul 2, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2FuanU=?=

    information about asp ,oracle,asp.net certification?

    =?Utf-8?B?c2FuanU=?=, May 18, 2005, in forum: Microsoft Certification
    Replies:
    1
    Views:
    489
    Bob Christian
    May 18, 2005
  2. Zabron Muyambo

    Easy Moving from ASP to ASP.NET???

    Zabron Muyambo, Oct 26, 2004, in forum: MCSD
    Replies:
    7
    Views:
    483
    Zabron Muyambo
    Oct 27, 2004
  3. thehobbit
    Replies:
    0
    Views:
    3,682
    thehobbit
    Nov 22, 2006
  4. london1919
    Replies:
    1
    Views:
    2,866
    Lawrence Garvin \(MVP\)
    Dec 8, 2008
  5. bhawneshkumar
    Replies:
    0
    Views:
    2,269
    bhawneshkumar
    Jul 17, 2009
Loading...

Share This Page