
Trace | 257
Page Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Example
The following code example sets the SmartNavigation property to True using the
SmartNavigation attribute of the @ Page directive. When the page is posted back,
only the current page will be stored in the browser’s history, so the Back button
will be disabled.
<%@ Page Language="vb" SmartNavigation="True" %>
<html>
<head>
<title>SmartNavigation property example</title>
<script runat="server">
Sub Page_Load( )
Message.Text = "This Label will change."
Message2.Text = "This Label will not change."
End Sub
Sub UpdateLabel(Sender As Object, e As EventArgs)
Message.Text = "This Label has changed."
End Sub
</script>
</head>
<body>
<form runat="server">
<asp:label id="Message" runat="server"/>
<asp:button id="update"
onClick="UpdateLabel"
text="Click to update label text"
runat="server"/>
</form>
<asp:label id="Message2" runat="server"/>
</body>
</html>
Notes
In addition to eliminating flicker when navigating or posting back, Smart-
Navigation maintains the current scroll position when a page is posted back and
maintains only a single page in the browser’s history, which prevents users from
clicking the browser’s Back button to go to a previous state of the page.
While you can set this property from code, it is recommended that this property
be set using the
SmartNavigation ...