当我点击按钮时我需要打开一个对话框,所以我这就是我所做的:
标记:
<ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/>
代码隐藏:
namespace Admin.Modules
{
public partial class UsersGrid : System.Web.UI.UserControl
{
protected void Button1_DirectClick(object sender, DirectEventArgs e)
{
X.Msg.Confirm("Confirm", "Do you want to update this information also?", new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Handler = "App.Direct.DoYes()",
Text = "Yes"
},
No = new MessageBoxButtonConfig
{
Handler = "WndwEdit.close()",
Text = "No"
}
}).Show();
}
[DirectMethod]
public void DoYes()
{
X.MessageBox.Info("Error NOT", "Something went lalala", AnchorPoint.LeftTop, UI.Danger).Show();
}
}
}
消息框显示正确,但它不会调用DoYes函数并显示错误:
未捕获的TypeError:无法读取未定义的属性“DoYes”
答案 0 :(得分:0)
您需要使用App.direct.DoYes而不是App.Direct.DoYes。
<%@ Page Language="C#" %>
<script runat="server">
protected void Button1_DirectClick(object sender, DirectEventArgs e)
{
X.Msg.Confirm("Confirm", "Do you want to update this information also?", new MessageBoxButtonsConfig
{
Yes = new MessageBoxButtonConfig
{
Handler = "App.direct.DoYes()",
Text = "Yes"
},
No = new MessageBoxButtonConfig
{
Handler = "WndwEdit.close()",
Text = "No"
}
}).Show();
}
[DirectMethod]
public void DoYes()
{
X.MessageBox.Info("Error NOT", "Something went lalala", AnchorPoint.LeftTop, UI.Danger).Show();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET Example</title>
<link type="text/css" rel="stylesheet" href="http://speed.ext.net/www/intro/css/main.css" />
</head>
<body>
<ext:ResourceManager runat="server" Theme="Triton" />
<ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/>
</body>
</html>