I need to open a dialog when I click a button so I here is what I have done:
Markup:
<ext:Button runat="server" ID="Button1" Text="Save New Information" OnDirectClick="Button1_DirectClick"/>
CodeBehind:
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();
}
}
}
The message box is displayed correctly but it doesnt call the DoYes function with error:
Uncaught TypeError: Cannot read property 'DoYes' of undefined
You need to use App.direct.DoYes not 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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.