When looking at the Page Sources, you will find the following code snippet.
Ext.onReady(function () {
Ext.ns("App.direct");
Ext.apply(App.direct, {
TestDirectMethod: function (config) {
return Ext.net.DirectMethod.request("TestDirectMethod", Ext.applyIf(config || {}, {}));
}
});
});
This is how a DirectMethod gets displayed in a browser.
Notice that it is enclosed within an Ext.onReady function. Therefore, your onReady function will be executed before this one.
If you want to ensure that our onReady function gets rendered before yours, you can use a ResourcePlaceHolder.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod]
public void TestDirectMethod()
{
X.Msg.Alert("DirectMethod", "Hello from Server!").Show();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
<ext:ResourcePlaceHolder runat="server" Mode="Script" />
<script>
Ext.onReady(function() {
App.direct.TestDirectMethod();
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
</form>
</body>
</html>
Click here for more information on the options available for a ResourcePlaceHolder's Mode.