when i call the session variable on pageload the following error occur

System.NullReferenceException: Object reference not set to an instance of an object.


the code was

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

religion.SelectedItem.Text = CStr(Session("name"))

Session.Remove("name")
end sub

in the Global.asax file at the Session_Start event, initialize your session variable with any value then you can use it latter on your code.

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.