Timer in ASP.Net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • csgraham74

    Timer in ASP.Net

    HI all,

    I want to implement this scenario: I need my ASP.NET website to
    check a SQL table every 30 seconds and if there is a change to display
    a message to user. I have created a panel control (pnlMessage) and
    placed the message on it also made it default to visible = false. I
    have placed a Timer control on my ASP.NET Web Form and set its Interval
    = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
    it hits the line pnlMessage.visi ble = True but the panel doesnt
    display. When I am debuging it also seems like the timer is still
    runnig regardles of me debugging and also all my cookies seems to be
    not readable any more. I think i am not using this control correctly
    can someone give me an example pls?

  • Jouni Karppinen

    #2
    RE: Timer in ASP.Net

    This is not exactly answer to your question, but is it possible to use more
    simple approach:
    <meta http-equiv="refresh" content="30">



    "csgraham74 " wrote:
    [color=blue]
    > HI all,
    >
    > I want to implement this scenario: I need my ASP.NET website to
    > check a SQL table every 30 seconds and if there is a change to display
    > a message to user. I have created a panel control (pnlMessage) and
    > placed the message on it also made it default to visible = false. I
    > have placed a Timer control on my ASP.NET Web Form and set its Interval
    > = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
    > it hits the line pnlMessage.visi ble = True but the panel doesnt
    > display. When I am debuging it also seems like the timer is still
    > runnig regardles of me debugging and also all my cookies seems to be
    > not readable any more. I think i am not using this control correctly
    > can someone give me an example pls?
    >
    >[/color]

    Comment

    • Cowboy (Gregory A. Beamer) - MVP

      #3
      RE: Timer in ASP.Net

      Because of the disconnected state of web apps, this is a tricky problem. Ajax
      (Asynch JavqaScript and XML) might be a solution (poll without refreshing the
      entire page) as would a page refresh (META tag will work here). With 2.0, you
      have the ability to send out a message when data is stale, which works
      extremely well in SQL Server 2005 (both due out Nov 7), but you still have to
      work a bit with the plumbing.

      If stale data is a problem due to editing, consider working in concurrency
      protection rather than polling, as it is easier to handle and well documented.

      --
      Gregory A. Beamer
      MVP; MCP: +I, SE, SD, DBA

      *************** ************
      Think Outside the Box!
      *************** ************


      "csgraham74 " wrote:
      [color=blue]
      > HI all,
      >
      > I want to implement this scenario: I need my ASP.NET website to
      > check a SQL table every 30 seconds and if there is a change to display
      > a message to user. I have created a panel control (pnlMessage) and
      > placed the message on it also made it default to visible = false. I
      > have placed a Timer control on my ASP.NET Web Form and set its Interval
      > = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
      > it hits the line pnlMessage.visi ble = True but the panel doesnt
      > display. When I am debuging it also seems like the timer is still
      > runnig regardles of me debugging and also all my cookies seems to be
      > not readable any more. I think i am not using this control correctly
      > can someone give me an example pls?
      >
      >[/color]

      Comment

      • Karl Seguin

        #4
        Re: Timer in ASP.Net

        Seems to me that you are expecting a timer, created on the server side, to
        work with the page framework dynamically. You can change the properties of
        controls up and including to the PreRender event. Remember, web programming
        is disconnected. Your page is already rendered to the browser adn there's
        no tie between the server code and the client anymore. This would work in
        windows client,but not web forms.

        Check out:


        it uses Ajax to poll a database for changes (sample #2). It should set you
        on the right track...

        Karl

        --
        MY ASP.Net tutorials
        Programming blog exploring Zig, Elixir, Go, Testing, Design and Performance

        "csgraham74 " <csgraham74@gma il.com> wrote in message
        news:1129118149 .214900.217730@ o13g2000cwo.goo glegroups.com.. .[color=blue]
        > HI all,
        >
        > I want to implement this scenario: I need my ASP.NET website to
        > check a SQL table every 30 seconds and if there is a change to display
        > a message to user. I have created a panel control (pnlMessage) and
        > placed the message on it also made it default to visible = false. I
        > have placed a Timer control on my ASP.NET Web Form and set its Interval
        > = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
        > it hits the line pnlMessage.visi ble = True but the panel doesnt
        > display. When I am debuging it also seems like the timer is still
        > runnig regardles of me debugging and also all my cookies seems to be
        > not readable any more. I think i am not using this control correctly
        > can someone give me an example pls?
        >[/color]


        Comment

        • Steve C. Orr [MVP, MCSD]

          #5
          Re: Timer in ASP.Net

          The server cannot raise an event to a client machine because of the
          disconnected architecture of the internet.
          All communications must be initiated by the client.
          Therefore you may want to have the browser request an update every 30
          seconds.

          Here are some options:

          You could use a refresh meta tag
          <meta http-equiv="refresh" content="30">

          You could use a JavaScript timer to refresh the page every so often:


          Dart has a really nice AJAX-based timer control:


          --
          I hope this helps,
          Steve C. Orr, MCSD, MVP



          "csgraham74 " <csgraham74@gma il.com> wrote in message
          news:1129118149 .214900.217730@ o13g2000cwo.goo glegroups.com.. .[color=blue]
          > HI all,
          >
          > I want to implement this scenario: I need my ASP.NET website to
          > check a SQL table every 30 seconds and if there is a change to display
          > a message to user. I have created a panel control (pnlMessage) and
          > placed the message on it also made it default to visible = false. I
          > have placed a Timer control on my ASP.NET Web Form and set its Interval
          > = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
          > it hits the line pnlMessage.visi ble = True but the panel doesnt
          > display. When I am debuging it also seems like the timer is still
          > runnig regardles of me debugging and also all my cookies seems to be
          > not readable any more. I think i am not using this control correctly
          > can someone give me an example pls?
          >[/color]


          Comment

          • logan

            #6
            Re: Timer in ASP.Net

            create a webservice. Add function to webservice to get data you need and in
            time interval that you want.
            Create a windows forms control that consumes the service and displays the
            status.
            Using the object tag put the control on the website.

            "csgraham74 " <csgraham74@gma il.com> wrote in message
            news:1129118149 .214900.217730@ o13g2000cwo.goo glegroups.com.. .[color=blue]
            > HI all,
            >
            > I want to implement this scenario: I need my ASP.NET website to
            > check a SQL table every 30 seconds and if there is a change to display
            > a message to user. I have created a panel control (pnlMessage) and
            > placed the message on it also made it default to visible = false. I
            > have placed a Timer control on my ASP.NET Web Form and set its Interval
            > = 30000 (30 seconds) it fires ok every 30 seconds and the code executes
            > it hits the line pnlMessage.visi ble = True but the panel doesnt
            > display. When I am debuging it also seems like the timer is still
            > runnig regardles of me debugging and also all my cookies seems to be
            > not readable any more. I think i am not using this control correctly
            > can someone give me an example pls?
            >[/color]


            Comment

            Working...