I bought this book yesterday and found one of the errors. On page 1, I modified this code, slightly different. The following code is available in privious. aspx.
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title ID = "title1" runat = "server"> No title page </title>
<Style type = "text/CSS">
# Container {
Border: 1px solid #333333;
Width: 500px;
Margin: 0px auto;
}
# Left {
Width: 80%;
Float: left;
}
# Right {
Width: 20%;
Float: left;
}
</Style>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div id = "Container">
<Div id = "Left">
<Asp: Calendar id = "calendar1" runat = "server" Height = "243px" width = "271px"> </ASP: Calendar>
</Div>
<Div id = "right">
<Asp: button id = "button1" runat = "server" text = "OK" postbackurl = "~ /Test/current. aspx "accesskey =" B "backcolor =" # c0ffff "bordercolor =" red "borderwidth =" 1px "/> </div>
</Div>
</Form>
</Body>
</Html>
Use the postbackurl attribute of the button to send the selected date of calendar1 on this page to current. aspx, but after using the above Code, no matter how you click the button, the page cannot be switched to current. ASPX page.
Sub page_load () sub page_load (byval sender as object, byval e as system. eventargs)
If page. iscrosspagepostback = true then
Dim Cale as calendar
Cale = ctype (previouspage. findcontrol ("calendar1"), calendar)
Label1.text = Cale. selecteddate. tostring
Else
Response. Redirect ("Previous. aspx ")
End if
End sub
If you remove current. in aspx, "If page. the iscrosspagepostback then statement can be switched, but cannot be determined from privious. aspx is coming, so it cannot be omitted. many similar problems are found in Google search, but no root cause is found. In fact, this judgment statement itself has a problem, and the root cause is privious. aspx transfers the value to current. aspx, not current. the iscrosspagepostback attribute of aspx is changed to true, privious. the iscrosspagepostback attribute of aspx is changed to true. Therefore, the judgment statement should be changed
IfPage. previouspage. iscrosspagepostback= True then .....
More details
In any case, the previouspage page attribute will contain objects that represent the previous page or the sender page. For example, if page a is sent to page B, the iscrosspagepostback attribute of page A (which can be accessed through the previouspage attribute) is true, and the previouspage attribute of page B has the name of page.