我正在尝试使用点击处理程序。我的功能是这样的(它们都在同一个类中):
[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' 未定义。”