Error Message:
System.NullReferenceException: Object reference not set to an instance of an object at contact.Default.button1Clicked (System.Object sender, System.EventArgs args) [0x00017] in /home/jess/Projects/contact/Default.aspx.vb:23 at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0 at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
VB Code:
Partial Public Class [Default]
Inherits System.Web.UI.Page
Public Overridable Sub button1Clicked(ByVal sender As Object, ByVal args As EventArgs)
dim firstName() as string
dim lastName() as string
dim email() as string
dim phone() as string
dim i as integer
do while i >=0
'assign variables to data inputed to textboxes
firstName(i) = txtFirstName.text
lastName(i) = txtLastName.text
email(i) = txtEmail.text
phone(i) = txtPhone.text
'display added contact information
lblName.text = firstName(i) + " " + lastName(i)
lblEmail.text = email(i)
lblPhone.text = phone(i)
loop
End Sub
End Class
default.aspx:
<html>
<head runat="server">
<title>Contact</title>
</head>
<body>
<form id="form1" runat="server">
<fieldset style="width: 250px">
<legend>Contact Information</legend>
<asp:Label id="lblFirstName" runat="server" WIDTH="75px">First Name:</asp:Label>
<asp:TextBox id="txtFirstName" runat="server" Width="155px"></asp:TextBox><br/>
<asp:Label id="lblLastName" runat="server" WIDTH="75px">Last Name:</asp:Label>
<asp:TextBox id="txtLastName" runat="server" Width="155px" ></asp:TextBox><br/>
<asp:Label id="lblEmail1"runat="server" WIDTH="75px">Email:</asp:Label>
<asp:TextBox id="txtEmail" runat="server" Width="155px"></asp:TextBox><br/>
<asp:Label id="lblPhone1" runat="server" WIDTH="75px">Phone:</asp:Label>
<asp:TextBox id="txtPhone" runat="server" Width="155px"></asp:TextBox> <br/>
<asp:Button id="button1" runat="server" Text="Add" OnClick="button1Clicked" style="float:right"/>
</fieldset>
</form>
<fieldset style="width: 250px">
<legend>Contacts Added</legend>
<asp:Label id="lblName" runat="server">
</asp:Label>
<br/>
<asp:Label id="lblEmail" runat="server">
</asp:Label>
<br/>
<asp:Label id="lblPhone" runat="server">
</asp:Label>
</fieldset>
</body>
</html>
SUGGESTIONS?
System.NullReferenceException: Object reference not set to an instance of an object at contact.Default.button1Clicked (System.Object sender, System.EventArgs args) [0x00017] in /home/jess/Projects/contact/Default.aspx.vb:23 at System.Web.UI.WebControls.Button.OnClick (System.EventArgs e) [0x00000] in <filename unknown>:0 at System.Web.UI.WebControls.Button.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent (System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandler sourceControl, System.String eventArgument) [0x00000] in <filename unknown>:0 at System.Web.UI.Page.RaisePostBackEvents () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRaiseEvents () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
VB Code:
Partial Public Class [Default]
Inherits System.Web.UI.Page
Public Overridable Sub button1Clicked(ByVal sender As Object, ByVal args As EventArgs)
dim firstName() as string
dim lastName() as string
dim email() as string
dim phone() as string
dim i as integer
do while i >=0
'assign variables to data inputed to textboxes
firstName(i) = txtFirstName.text
lastName(i) = txtLastName.text
email(i) = txtEmail.text
phone(i) = txtPhone.text
'display added contact information
lblName.text = firstName(i) + " " + lastName(i)
lblEmail.text = email(i)
lblPhone.text = phone(i)
loop
End Sub
End Class
default.aspx:
<html>
<head runat="server">
<title>Contact</title>
</head>
<body>
<form id="form1" runat="server">
<fieldset style="width: 250px">
<legend>Contact Information</legend>
<asp:Label id="lblFirstName" runat="server" WIDTH="75px">First Name:</asp:Label>
<asp:TextBox id="txtFirstName" runat="server" Width="155px"></asp:TextBox><br/>
<asp:Label id="lblLastName" runat="server" WIDTH="75px">Last Name:</asp:Label>
<asp:TextBox id="txtLastName" runat="server" Width="155px" ></asp:TextBox><br/>
<asp:Label id="lblEmail1"runat="server" WIDTH="75px">Email:</asp:Label>
<asp:TextBox id="txtEmail" runat="server" Width="155px"></asp:TextBox><br/>
<asp:Label id="lblPhone1" runat="server" WIDTH="75px">Phone:</asp:Label>
<asp:TextBox id="txtPhone" runat="server" Width="155px"></asp:TextBox> <br/>
<asp:Button id="button1" runat="server" Text="Add" OnClick="button1Clicked" style="float:right"/>
</fieldset>
</form>
<fieldset style="width: 250px">
<legend>Contacts Added</legend>
<asp:Label id="lblName" runat="server">
</asp:Label>
<br/>
<asp:Label id="lblEmail" runat="server">
</asp:Label>
<br/>
<asp:Label id="lblPhone" runat="server">
</asp:Label>
</fieldset>
</body>
</html>
SUGGESTIONS?