Mar 30, 2016, 6:52 PM
[CLOSED] How to use the History control?
Hi,
I'm trying to mimic the behavior of "blocking" the use of the browser "Back" button. When the user attempts to navigate backwards, a prompt should be presented and page location remain the same. The prompt should not fire when the page initially loads, which is the problem of the code sample below. It seems that the call to suspend events on the History control has no bearing on it so when the token is sent, the change event always fires. Please suggest how to fix it.
I'm trying to mimic the behavior of "blocking" the use of the browser "Back" button. When the user attempts to navigate backwards, a prompt should be presented and page location remain the same. The prompt should not fire when the page initially loads, which is the problem of the code sample below. It seems that the call to suspend events on the History control has no bearing on it so when the token is sent, the change event always fires. Please suggest how to fix it.
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
<script type="text/javascript">
var onDocumentReady = function () {
History1.suspendEvents(false);
History1.add("Main");
History1.resumeEvents();
};
var blockBackButton = function () {
History1.add("Main");
Ext.Msg.alert("Alert", "Back button is disabled!");
};
</script>
</head>
<body>
<ext:ResourceManager runat="server">
<Listeners>
<DocumentReady Fn="onDocumentReady" />
</Listeners>
</ext:ResourceManager>
<form id="form1" runat="server">
<ext:History ID="History1" runat="server">
<Listeners>
<Change Fn="blockBackButton" />
</Listeners>
</ext:History>
</form>
</body>
</html>
Last edited by fabricio.murta; Apr 06, 2016 at 2:50 PM.