C#确认CodeBehind中的消息处理程序
当我点击一个按钮时,我需要打开一个对话框,这样我就完成了以下工作: 标记:C#确认CodeBehind中的消息处理程序,c#,ext.net,C#,Ext.net,当我点击一个按钮时,我需要打开一个对话框,这样我就完成了以下工作: 标记: <ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/> 消息框显示正确,但未调用DoYes函数,出现错误: 未捕获的TypeError:无法读取未定义的属性“DoYes” 您需要使用App.direct.DoYes而不是App.direct.DoYes
<ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/>
消息框显示正确,但未调用DoYes函数,出现错误:
未捕获的TypeError:无法读取未定义的属性“DoYes”
您需要使用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>
受保护的无效按钮1\u直接单击(对象发送方,DirectEventArgs e)
{
X.Msg.Confirm(“确认”,“是否也要更新此信息?”,new MessageBoxButtonsConfig
{
是=新建MessageBox按钮图
{
Handler=“App.direct.DoYes()”,
Text=“是”
},
否=新建MessageBoxButtonConfig
{
Handler=“WndwEdit.close()”,
Text=“否”
}
}).Show();
}
[直接法]
公共无效DoYes()
{
X.MessageBox.Info(“没有错误”,“有东西出了问题”,AnchorPoint.LeftTop,UI.Danger).Show();
}
Ext.NET示例
请在代码段中包含命名空间和类定义。@ChrisPickford ok done从未使用过ext.net我不熟悉它们的DirectMethod
拓扑结构,但是您的错误表明DoYes()
方法未在App.Direct
命名空间上定义。尝试使用[DirectMethod(Namespace=“???”]”]
。我尝试使用特定的命名空间,但在使用App.direct.DoYes时均无效。我收到此错误:未捕获类型错误:App.direct.DoYes不是函数尝试将[DirectMethod]更改为[DirectMethod(Namespace=“App.direct”)]此外,请检查web.config中此值的值:directMethodNamespace更多信息,请参见:
<%@ 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>