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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How can i make ..

How can i make ..

Scheduled Pinned Locked Moved C#
question
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.
  • A Offline
    A Offline
    Ahmed EL Gendy
    wrote on last edited by
    #1

    hi all here i want to know ,that if it is posible to make a variable that i can control it from any page from my website ??? if yes , HoW can i do this ?? Ex: String X ; page.aspx page2.aspx page3.aspx x = "abc"; x = "def"; x = "ghi"; i hope that any one understand what i mean. best regards Ahemd EL GEndy

    G E 2 Replies Last reply
    0
    • A Ahmed EL Gendy

      hi all here i want to know ,that if it is posible to make a variable that i can control it from any page from my website ??? if yes , HoW can i do this ?? Ex: String X ; page.aspx page2.aspx page3.aspx x = "abc"; x = "def"; x = "ghi"; i hope that any one understand what i mean. best regards Ahemd EL GEndy

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The Application object has a collection where you can put variables. As the Application object is global for the application, any page can use the variable. Example: Application["info"] = "asdf"; string info = (string)Application["info"]; When changing application variables you can use Application.Lock and Application.Unlock to make sure that only one page has access to the variables at the moment.

      --- single minded; short sighted; long gone;

      1 Reply Last reply
      0
      • A Ahmed EL Gendy

        hi all here i want to know ,that if it is posible to make a variable that i can control it from any page from my website ??? if yes , HoW can i do this ?? Ex: String X ; page.aspx page2.aspx page3.aspx x = "abc"; x = "def"; x = "ghi"; i hope that any one understand what i mean. best regards Ahemd EL GEndy

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        Guffa's answer will work if you want an application global. However, from reading, it seems you may want

        Session["something"] = 12;
        int i = (int)Session["something"];

        Also, i you will be managing a large amount of data between pages in session, or application, I would consider creating a serializable object that can be used. Also, instead of retrieving the object from session or application create a static method of the object to retrieve itself.

        public class SomeClass{
        private const string SESSION_KEY = "SomeClass";

        public static SomeClass GetInstance(Page page){
            if(Session\[SESSION\_KEY\] == null)
                Session\[SESSION\_KEY\] = new SomeClass();
             return (SomeClass)Session\[SESSION\_KEY\];
        }
        
        private SomeClass(){}
        

        }


        File Not Found

        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