I have control leviMenu.ascx, where I define session:
If HttpContext.Current.Session("user") Is Nothing Then
Dim uporabnik(2)
uporabnik(0) = "1"
uporabnik(1) = "Simon Zupan"
uporabnik(2) = "2"
Session("user") = uporabnik
End If
Then I register it on the page:
<%@ Register TagPrefix ="Menu" TagName = "LeviMenu" Src =
"userControls\leviMenu.ascx"%>
then use it on page:
<menu:leviMenu runat="server" ID="Levimenu1"></menu:leviMenu>
Then on the same page in Private Sub Page_Load event, I'm reading the value
from session:
HttpContext.Current.Session("user")(0)
And I gett an error message:
System.NullReferenceException: Object variable or With block variable not
set.
The session object is not recognized.
How can I solve this problem?
I have session object in user control because it's registered on all pages.
I can write the session code on each page separeted, it works than, but than
I don't have the code on one place, it doesn't make any sence.
Thank you,
Simon