PDA

View Full Version : Ext.Direct Simple Yet Confusing... HELP!



cgountanis
16 Nov 2009, 10:52 AM
Why can I not change the class name Sample to anything and not have it break??? I change Sample to Sample2 for example then in the App.js I change calls to MyApp.Sample.* to MyApp.Sample2.* then I get e is not defined or just a white blank page. This is very annoying. Does everyone just develop with the class Sample only?



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Direct;
using Newtonsoft.Json.Linq;

namespace ExtDirectSample
{
[DirectAction]
public class Sample : DirectHandler
{
public override string ProviderName
{
get
{
return "Ext.app.REMOTING_API";
}
}

public override string Namespace
{
get
{
return "MyApp";
}
}

[DirectMethod]
public string GetTime()
{
return DateTime.Now.ToLongTimeString();
}
}
}

cgountanis
16 Nov 2009, 10:58 AM
ASHX


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Direct;
using Newtonsoft.Json.Linq;

namespace ExtDirectSample
{
[DirectAction]
public class test1 : DirectHandler
{
public override string ProviderName
{
get
{
return "Ext.app.REMOTING_API";
}
}

public override string Namespace
{
get
{
return "MyApp";
}
}

[DirectMethod]
public string GetTime()
{
return DateTime.Now.ToLongTimeString();
}
}
}


JS


Ext.Direct.addProvider(Ext.app.REMOTING_API);
Ext.onReady(function(){

var time = new Ext.Panel({
title: 'Time check',
flex: 1,
tools: [{
id: 'refresh',
handler: function(){
MyApp.test1.GetTime(function(e, result){
time.body.update(result.result);
});
}
}]
});

var ct = new Ext.Viewport({
autoEl: {},
layout: 'hbox',
layoutConfig: {
align: 'stretch'
},
items: [time],
renderTo: document.body
});
});



Error:
Error: e is undefined
Source File: ext-all.js
Line: 7

cgountanis
16 Nov 2009, 1:56 PM
OK, I figured it out it was a dumb mistake. When you change the class or name space pretty sure this was the issue. I totally forgot about that part of the page.

<%@ WebHandler Language="C#" CodeBehind="DirectHandler.ashx.cs" Class="CHANGEMETOO!.DirectHandler" %>