Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. An interesting problem...

An interesting problem...

Scheduled Pinned Locked Moved Web Development
csharphelpjavascripthtmlasp-net
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tantiboh
    wrote on last edited by
    #1

    I've encountered an interesting problem to which I can't seem to find a solution. I've got an ASP.NET application, written in C#, that returns a variable called TimeToRefresh each time that the page loads. This variable is determined dynamically, represents the number of milliseconds before the page needs to automatically refresh, and could be any positive integer. Since I need an automatic page refresh, that necessitates JavaScript (if there's another client-side method for automatic page refresh that could be adapted to this problem, please let me know). I need to implement, therefore, a JavaScript timer that counts down the number of milliseconds indicated in the TimeToRefresh variable. Here's the rub: I can't find a way to transfer the variable from ASP.NET to JavaScript. I need to either: a.) access an ASP control from JavaScript, or b.) populate an html control from ASP that can then be accessed by JavaScript. I can't seem to do either successfully. Any ideas? Another method entirely, perhaps? Thanks for your help!

    D S 2 Replies Last reply
    0
    • T tantiboh

      I've encountered an interesting problem to which I can't seem to find a solution. I've got an ASP.NET application, written in C#, that returns a variable called TimeToRefresh each time that the page loads. This variable is determined dynamically, represents the number of milliseconds before the page needs to automatically refresh, and could be any positive integer. Since I need an automatic page refresh, that necessitates JavaScript (if there's another client-side method for automatic page refresh that could be adapted to this problem, please let me know). I need to implement, therefore, a JavaScript timer that counts down the number of milliseconds indicated in the TimeToRefresh variable. Here's the rub: I can't find a way to transfer the variable from ASP.NET to JavaScript. I need to either: a.) access an ASP control from JavaScript, or b.) populate an html control from ASP that can then be accessed by JavaScript. I can't seem to do either successfully. Any ideas? Another method entirely, perhaps? Thanks for your help!

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      maybe I missed something, but you can generate JS from ASP.NET. See Injecting Client-Side Script from an ASP.NET Server Control[^] David

      1 Reply Last reply
      0
      • T tantiboh

        I've encountered an interesting problem to which I can't seem to find a solution. I've got an ASP.NET application, written in C#, that returns a variable called TimeToRefresh each time that the page loads. This variable is determined dynamically, represents the number of milliseconds before the page needs to automatically refresh, and could be any positive integer. Since I need an automatic page refresh, that necessitates JavaScript (if there's another client-side method for automatic page refresh that could be adapted to this problem, please let me know). I need to implement, therefore, a JavaScript timer that counts down the number of milliseconds indicated in the TimeToRefresh variable. Here's the rub: I can't find a way to transfer the variable from ASP.NET to JavaScript. I need to either: a.) access an ASP control from JavaScript, or b.) populate an html control from ASP that can then be accessed by JavaScript. I can't seem to do either successfully. Any ideas? Another method entirely, perhaps? Thanks for your help!

        S Offline
        S Offline
        Scott Serl
        wrote on last edited by
        #3

        You could add a html hidden control to the page and make it server side (right click / run at server). Then you can populate the control server side and read it from javascript via getElementById(idOfHiddenElement).

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups