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. Access a control or function from asp page in Global.asax

Access a control or function from asp page in Global.asax

Scheduled Pinned Locked Moved ASP.NET
questiontutorial
5 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.
  • S Offline
    S Offline
    SajjadZare
    wrote on last edited by
    #1

    How can i access a control or function from asp page in Global.asax? for example call a function from Default.aspx in Global.asax

    S 1 Reply Last reply
    0
    • S SajjadZare

      How can i access a control or function from asp page in Global.asax? for example call a function from Default.aspx in Global.asax

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Why would you want to do such thing? Global.asax has it's own responsibilities and triggers.

      Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

      S 1 Reply Last reply
      0
      • S Sandeep Mewara

        Why would you want to do such thing? Global.asax has it's own responsibilities and triggers.

        Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

        S Offline
        S Offline
        SajjadZare
        wrote on last edited by
        #3

        I implement a background task for check new email in Global and want to update label's text that put in page.aspx from Global

        S 1 Reply Last reply
        0
        • S SajjadZare

          I implement a background task for check new email in Global and want to update label's text that put in page.aspx from Global

          S Offline
          S Offline
          Sandeep Mewara
          wrote on last edited by
          #4

          SajjadZare wrote:

          background task for check new email in Global

          That's not the right place for some utility method. Create and place a new class in App_Code folder. Expose the method and use it in your pages where needed. Global.asax is not for such things. Please read about it.

          Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

          S 1 Reply Last reply
          0
          • S Sandeep Mewara

            SajjadZare wrote:

            background task for check new email in Global

            That's not the right place for some utility method. Create and place a new class in App_Code folder. Expose the method and use it in your pages where needed. Global.asax is not for such things. Please read about it.

            Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Blog]: Sandeep Mewara's Tech Journal! [My Latest Article]: HTML5 Quick Start Web Application

            S Offline
            S Offline
            SajjadZare
            wrote on last edited by
            #5

            I need to check a function every 60 seconds and do that with below code

            void Application_Start(object sender, EventArgs e)
            {
            AddTask("CheckEmails", 60);
            }

            private void AddTask(string name, int seconds)
            {
                OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
                HttpRuntime.Cache.Insert(name, seconds, null, DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
                    CacheItemPriority.NotRemovable, OnCacheRemove);
            }//addTask
            
            public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
            {
                //check for new emails
            
                AddTask(k, Convert.ToInt32(v));
            }//CacheItemRemoved
            
            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