Reputation: 172538
I have created a Application variable to in my Global.asax.cs file with the below code:-
protected void Application_Start(Object sender, EventArgs e)
{
Application["Visitors"] = 0;
}
protected void Session_Start(Object sender, EventArgs e)
{
Application.Lock();
Application["Visitors"] = Convert.ToInt32(Application["Visitors"]) + 1;
Application.UnLock();
}
protected void Session_End(Object sender, EventArgs e)
{
Application["Visitors"] = Convert.ToInt32(Application["Visitors"]) - 1;
}
Now I want to use this Application["Visitor"]
variable in my Classic aspx page. I am writing below code for this but it is giving me error:-
Sub window_onLoad ()
dim i
i= Application["Visitors"].ToString()
End sub
Could you please help me in using this variable on different aspx pages?
Upvotes: 1
Views: 179
Reputation: 2170
Are you trying to get the server side Application
values on client side VB script? Is it so? than I think it is not possible, you will have to do it in server side code.
Upvotes: 0
Reputation: 16144
If you are using vb.net, use have to use () brackets instead of []:
Sub window_onLoad ()
dim i
i= Application("Visitors").ToString()
End sub
Upvotes: 2