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. update global.asax variable from javascript

update global.asax variable from javascript

Scheduled Pinned Locked Moved ASP.NET
javascripthelptutorialquestionannouncement
8 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.
  • M Offline
    M Offline
    Munteanu Ciprian
    wrote on last edited by
    #1

    Hi! I have a global variable which is initialized in Global.asax (in the Session_start event). Now I want using Javascript to update this variable and I don't know how to do that. Why I have to do that? Because I used javascript to create a small timer which, at every 10 minutes I want to increase the variable by 1. Can anyone help me please?

    P 1 Reply Last reply
    0
    • M Munteanu Ciprian

      Hi! I have a global variable which is initialized in Global.asax (in the Session_start event). Now I want using Javascript to update this variable and I don't know how to do that. Why I have to do that? Because I used javascript to create a small timer which, at every 10 minutes I want to increase the variable by 1. Can anyone help me please?

      P Offline
      P Offline
      Petr Pechovic
      wrote on last edited by
      #2

      Hi Munteanu, Create a page or a web service to increase your value. Use AJAX request to call the page/web service. For the web service you can use generated proxy javascript classes to call it. For the page you can use for example jquery to call it. http://docs.jquery.com/Ajax

      Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

      M 1 Reply Last reply
      0
      • P Petr Pechovic

        Hi Munteanu, Create a page or a web service to increase your value. Use AJAX request to call the page/web service. For the web service you can use generated proxy javascript classes to call it. For the page you can use for example jquery to call it. http://docs.jquery.com/Ajax

        Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

        M Offline
        M Offline
        Munteanu Ciprian
        wrote on last edited by
        #3

        Can you give me an example please? (with some code)

        P 1 Reply Last reply
        0
        • M Munteanu Ciprian

          Can you give me an example please? (with some code)

          P Offline
          P Offline
          Petr Pechovic
          wrote on last edited by
          #4

          Hi, just create ASP.NET page. On page_load increment your value.

          public partial class my_page : System.Web.UI.Page {

              protected void Page\_Load(object sender, EventArgs e) {
                  // increment your value
              }
          }
          

          from the JavaScript call your page:

          $.get('my_page.aspx');

          Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

          M 1 Reply Last reply
          0
          • P Petr Pechovic

            Hi, just create ASP.NET page. On page_load increment your value.

            public partial class my_page : System.Web.UI.Page {

                protected void Page\_Load(object sender, EventArgs e) {
                    // increment your value
                }
            }
            

            from the JavaScript call your page:

            $.get('my_page.aspx');

            Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

            M Offline
            M Offline
            Munteanu Ciprian
            wrote on last edited by
            #5

            Are you sure this is the correct way to call the page in javascript: "$.get('my_page.aspx');"? I've tried and it's not working...

            P 1 Reply Last reply
            0
            • M Munteanu Ciprian

              Are you sure this is the correct way to call the page in javascript: "$.get('my_page.aspx');"? I've tried and it's not working...

              P Offline
              P Offline
              Petr Pechovic
              wrote on last edited by
              #6

              yes :) you have to download the jQuery library and add the script reference to it. It's just one file. Here: jQuery mini[^]

              Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

              M 1 Reply Last reply
              0
              • P Petr Pechovic

                yes :) you have to download the jQuery library and add the script reference to it. It's just one file. Here: jQuery mini[^]

                Petr Pechovic my latest articles: Web Page Loading in Steps - ASP.NET Solution[^] Buttons, Message Box and Confirm Box in ASP.NET 3.5[^]

                M Offline
                M Offline
                Munteanu Ciprian
                wrote on last edited by
                #7

                And how do I add the script reference and where should I put the file?

                M 1 Reply Last reply
                0
                • M Munteanu Ciprian

                  And how do I add the script reference and where should I put the file?

                  M Offline
                  M Offline
                  Munteanu Ciprian
                  wrote on last edited by
                  #8

                  I've done it! Thanks a lot for your time and help!

                  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