I need help with the following : In the Homework.Master page, open the code file
ID: 3664652 • Letter: I
Question
I need help with the following :
In the Homework.Master page, open the code file. You need to write the code to show the application and session variables. Note that you need to use the square brackets! You have to use ToString to convert the values to strings.
This is what i have in writen seems to me that i am missing something. Please help !!!
public partial class Homework : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
lblOnlineUsers.Text = "Online Users: " + Application[OnlineUsers];
lblTotalVisitors.Text = "Total Visitors: " + Application[TotalVisitors];
}
}
Explanation / Answer
if (Session["TotalVisitors"] != null)
{
int TotalVisitors = (int)Session["TotalVisitors"];
lblTotalVisitors.Text = "Total Visitors: " + Application[TotalVisitors].toString();
}
if (Session["OnlineUsers"] != null)
{
int> lblOnlineUsers.Text = "Online Users: " + Application[OnlineUsers].toString();
}