<asp:ListBox ID="lstEducation" runat="server" Width="205px">
<asp:ListItem >High School</asp:ListItem>
<asp:ListItem>Associate's Degree</asp:ListItem>
<asp:ListItem>Four-Year College</asp:ListItem>
<asp:ListItem>Masters</asp:ListItem>
<asp:ListItem>PhD</asp:ListItem>
</asp:ListBox>
This error occurs in page load at:Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 62: ddlMaterialStatus.SelectedItem.Text = Session("maritalStatus")
Line 63:
Line 64: lstEducation.SelectedItem.Text = Session("education")
Line 65: chkAddComment.Checked = Session("addComment")
Line 66: txtComment.Text = Session("comment")
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
addContact.Page_Load(Object sender, EventArgs e) in ... AddContact.aspx.vb:64
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
ASKER
ASKER
ASKER
<asp:ListBox ID="lstEducation" runat="server" Width="205px">
<asp:ListItem Selected="True">High School</asp:ListItem>
<asp:ListItem>Associate's Degree</asp:ListItem>
<asp:ListItem>Four-Year College</asp:ListItem>
<asp:ListItem>Masters</asp:ListItem>
<asp:ListItem>PhD</asp:ListItem>
</asp:ListBox>
ASKER
ASKER
The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.
TRUSTED BY
Try moving your code in Page_LoadComplete. This ensures that the controls have been loaded.
Giannis