Apr 25, 2011, 6:56 PM
[CLOSED] "Ext is undefined" - error in simple javascript when calling DirectMethod
So I have my Default.aspx and trying to do some "keepalive" so that the session doesnt time out all the time.
The page inherits a MasterPage and in the head I place this:
Uncaught ReferenceError: Ext is not defined
I have also tried this approach in calling DirectMethod:
The page inherits a MasterPage and in the head I place this:
<%@ Page Language="C#" MasterPageFile="SiteSecure.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplicationExtNetTest.Secure.Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<asp:Content ID="asd" ContentPlaceHolderID="head" runat="server">
<ext:XScript runat="server">
<script type="text/javascript">
var timerObj;
function KeepAlive() {
#{DirectMethods}.SendKeepAlive();
timerObj = setTimeout("KeepAlive()", 1000 * 30);
}
KeepAlive();
</script>
</ext:XScript>
</asp:Content>
The code-behind:[DirectMethod]
public void SendKeepAlive()
{
DateTime start = DateTime.Now;
KeepAlivePingWithReply asd = new KeepAlivePingWithReply();
asd = (KeepAlivePingWithReply)SRef.main.SendRequest(asd);
if (asd != null && asd.Success)
{
TimeSpan ts = DateTime.Now.Subtract(start);
ToolbarTextItem2.Text = asd._ServerTime.ToLongTimeString() + " (" + ts.TotalMilliseconds + " ms)";
}
else
{
ToolbarTextItem2.Text = "No server reply";
X.Msg.Alert("Error", "EPIC FAIL");
}
}
Easy enough. Problem is that I get the following error in the browser:Uncaught ReferenceError: Ext is not defined
I have also tried this approach in calling DirectMethod:
function KeepAlive() {
Ext.net.DirectMethods.SendKeepAlive();
timerObj = setTimeout("KeepAlive()", 1000 * 30);
}
But same error. Its weird, because I call DirectMethods from Javascript in other pages without problems. I cant see the error...