1

我正在尝试使用点击处理程序。我的功能是这样的(它们都在同一个类中):

[DirectMethod]
protected bool Save()
{
      //do work
}

我试图用以下方式调用它:

using (Ext.Net.Button yes = new Ext.Net.Button())
{
     // random set up for button

     // failed because it couldn't find namespace
     yes.Listeners.Click.Handler = "Namespace.Class.Save();";

     // attempt 2: removed the first one and assumed that the [DirectMethod] sets
     // it to be Ext.net.DirectMethods.Save();
     yes.Listeners.Click.Handler = "Ext.net.DirectMethods.Save();"

}

第一次失败无法找到命名空间,第二次失败是因为“对象不支持此属性或方法”。

我用什么字符串来渲染这个?如果不是Listeners.Click.Handler顺便说一句,我还能怎么做?

该函数位于扩展的自定义控件中,而使用项位于呈现控件Ext.Net.Window的调用函数中。Display()

根据 vladsch 的回复,我已将其更改为:

 [DirectMethod(Namespace="MyMethods")]
 public bool Save()
 {
      //do work
 }

处理程序字符串现在是:

 yes.Listeners.Click.Handler = "MyMethods.Save();"

这样做时,我得到“'MyMethods' 未定义。”

4

2 回答 2

3

DirectMethod 必须是公共的您也可以定义自己的命名空间(而不是 Ext.net.DirectMethods)[DirectMethod(Namespace="MyDirectMethods")]

于 2011-12-21T21:03:31.967 回答
0

Daniil 的 Ext.NET 论坛帖子

Using X.GetCmp I was able to retrieve the data. It probably isn't the best way possible (probably a way without postback), but it at least netted the results I needed.

于 2012-02-09T17:05:09.810 回答