Articles → LIGHT SWITCH 2011 → Global variables in lightswitch 2011

Global variables in lightswitch 2011
























Software requirement











Prerequisite knowledge













Steps of execution

















Create a new project





Click to Enlarge


Add screens





Click to Enlarge


Add global variable in application.cs









Click to Enlarge



namespace LightSwitchApplication
{
    public partial class Application
    {
        public string MyGlobalVariable { get; set; }
    }
}



Set global variable in screen 1




namespace LightSwitchApplication
{
    public partial class Screen1
    {
        partial void Screen1_Created()
        {
            // Write your code here.
            Application.MyGlobalVariable = "Global Variable Set in Screen 1";
            Application.ShowScreen2();
        }
    }
}





Get global variable in screen 2




using Microsoft.LightSwitch.Presentation.Extensions;

namespace LightSwitchApplication
{
    public partial class Screen2
    {
        partial void Screen2_Created()
        {
            this.ShowMessageBox(Application.MyGlobalVariable);
        }
    }
}





Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, March 26, 2013

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250