How can I access a variable in Global.asax.cs

This is my current nonworking code .....

my code in Global.asax.cs

public class Global : System.Web.HttpApplication 
        { 
           public string GlobalMethod = "En exempeltext......."; 
        }

my code in default.cs

What I like to do later is to print the result in a label. But now I first need to get access to the variable in Global.sax.cs.

protected void Button9_Click(object sender, EventArgs e) 
        { 
            Global getitnow = new Global(); 
            getitnow.GlobalMethod(); 
        }

in your global.asax public static string GlobalMethod = "example"; in your page class lblYourLable.Text = Global.GlobalMethod; if your Global.asax.cs has a namespace then use: YourNamespaceName.Global.GlobalMethod

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.