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. ASP.NET
  4. JavaScript variable from ASP form?

JavaScript variable from ASP form?

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlsysadmintoolshelp
2 Posts 2 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

    Here's my situation. I've got an ASPX page that needs to be refreshed with new content every few seconds, but that amount of time is variable. I'm sending that variable to the page from the server-side application on every refresh. That way, theoretically, the page can automatically refresh when that variable amount of time is elapsed and thereby get a new amount of time to count down. Setting up a JavaScript reload function is easy enough, but I can't find a way to get that ASP variable into the Javascript, as the JavaScript seems to be able to only access HTML form components and not ASP form objects. So, I either need a way to get an ASP variable into the JavaScript, or I need a different client-side script that can actually get that variable from an ASP control and is still capable of causing a PostBack like JavaScript can. Any ideas? Thanks for your help!

    M 1 Reply Last reply
    0
    • T tantiboh

      Here's my situation. I've got an ASPX page that needs to be refreshed with new content every few seconds, but that amount of time is variable. I'm sending that variable to the page from the server-side application on every refresh. That way, theoretically, the page can automatically refresh when that variable amount of time is elapsed and thereby get a new amount of time to count down. Setting up a JavaScript reload function is easy enough, but I can't find a way to get that ASP variable into the Javascript, as the JavaScript seems to be able to only access HTML form components and not ASP form objects. So, I either need a way to get an ASP variable into the JavaScript, or I need a different client-side script that can actually get that variable from an ASP control and is still capable of causing a PostBack like JavaScript can. Any ideas? Thanks for your help!

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. If you're already setting up the javascript function, allow it to accept a parameter. Then from your server-side code, render the appropriate javascript call to start the timer with the parameter hard-coded.

      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