On the textbook page 74, List 3-13. when I tried to run it. I can't get the label content on the second page. It always leads me to "Page1.aspx". Is there some problem with my code. I only changed the PostBackURl property on the first page. I changed to PostBackUrl="Page2 - Listing 03-13.aspx". Also, according to listing 3-13. I changed <%@ PreviousPageType VirtualPath="Page1 - Listing 03-11.aspx" %> field.
Any help will be greatly appreciated.
First page:
<%@ Page Language="
VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public ReadOnly Property pp_TextBox1() As TextBox
Get
Return TextBox1
End Get
End Property
Public ReadOnly Property pp_Calendar1() As Calendar
Get
Return Calendar1
End Get
End Property
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = "Hello " & TextBox1.Text & "<br /><br />" & _
"Date Selected: " & Calendar1.SelectedDate.ToLongDateString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>First Page</title>
</head>
<body>
<form id="form1" runat="server">
Enter your name:<br />
<asp:Textbox ID="TextBox1" Runat="server">
</asp:Textbox>
<p>
When do you want to fly?<br />
<asp:Calendar ID="Calendar1" Runat="server"></asp:Calendar></p>
<br />
<asp:Button ID="Button1" Runat="server" Text="Submit page to itself"
OnClick="Button1_Click" />
<asp:Button ID="Button2" Runat="server" Text="Submit page to Page2.aspx"
PostBackUrl="Page2 - Listing 03-13.aspx" />
<p>
<asp:Label ID="Label1" Runat="server"></asp:Label></p>
</form>
</body>
</html>
Second page:
<%@ Page Language="
VB" %>
<%@ PreviousPageType VirtualPath="Page1 - Listing 03-11.aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Page.IsCrossPagePostBack Then
Label1.Text = "Hello " & PreviousPage.pp_Textbox1.Text & "<br />" & _
"Date Selected: " & _
PreviousPage.pp_Calendar1.SelectedDate.ToShortDate String()
Else
Response.Redirect("Page1 - Listing 03-11.aspx")
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Second Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="Label1" Runat="server"></asp:Label>
</form>
</body>
</html>
I am a database programmer and .Net programmer