Null Reference Exception Listing 1-10
Hello All,
I just tried to use the following code from the book and received the error
Null Reference Exception was unhandled by user code.
My code is as follows.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Listing1-10.aspx.cs" Inherits="WebApplication1.Listing1_10" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
TextBox pp_TextBox1;
Calendar pp_Calendar1;
pp_TextBox1 = (TextBox)PreviousPage.FindControl("TextBox1");
pp_Calendar1 = (Calendar)PreviousPage.FindControl("Calendar1");
Label1.Text = "Hello " + pp_TextBox1.Text + "<br />" + "Date Selected " +
pp_Calendar1.SelectedDate.ToShortDateString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
Any ideas?
Regards
Tomche
|