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
"Arthur Nesterovsky" <ar********************@nesterovsky-bros.com> wrote in
message news:Oz**************@TK2MSFTNGP09.phx.gbl...
Hi,
I had line:
If Session("user") Is Nothing Then
response.redirect "login.asp"
End If
Now I move all my functions to user control (by the book) and register
it on all my pages - approximate the similar like with include.
Try to check
HttpContext.Current.Session("user") instead.
--
______________________________
With best wishes, Arthur Nesterovsky
Please visit my home page:
http://www.nesterovsky-bros.com